Source Code Cross Referenced for AbstractVector.java in  » IDE » J » org » armedbear » lisp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » J » org.armedbear.lisp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * AbstractVector.java
003:         *
004:         * Copyright (C) 2003-2004 Peter Graves
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         */
020:
021:        package org.armedbear.lisp;
022:
023:        public abstract class AbstractVector extends AbstractArray {
024:            public LispObject typep(LispObject type) throws ConditionThrowable {
025:                if (type == Symbol.VECTOR)
026:                    return T;
027:                if (type == BuiltInClass.VECTOR)
028:                    return T;
029:                if (type == Symbol.SEQUENCE)
030:                    return T;
031:                if (type == BuiltInClass.SEQUENCE)
032:                    return T;
033:                return super .typep(type);
034:            }
035:
036:            public final LispObject VECTORP() {
037:                return T;
038:            }
039:
040:            public final boolean vectorp() {
041:                return true;
042:            }
043:
044:            public boolean equalp(LispObject obj) throws ConditionThrowable {
045:                if (obj instanceof  AbstractVector) {
046:                    if (length() != obj.length())
047:                        return false;
048:                    AbstractVector v = (AbstractVector) obj;
049:                    for (int i = length(); i-- > 0;)
050:                        if (!getRowMajor(i).equalp(v.getRowMajor(i)))
051:                            return false;
052:                    return true;
053:                }
054:                return false;
055:            }
056:
057:            public int getRank() {
058:                return 1;
059:            }
060:
061:            public final LispObject getDimensions() {
062:                return new Cons(new Fixnum(capacity()));
063:            }
064:
065:            public final int getDimension(int n) throws ConditionThrowable {
066:                if (n != 0) {
067:                    signal(new TypeError("bad dimension for vector"));
068:                    // Not reached.
069:                    return 0;
070:                }
071:                return capacity();
072:            }
073:
074:            public final int getTotalSize() {
075:                return capacity();
076:            }
077:
078:            public abstract int capacity();
079:
080:            public abstract LispObject subseq(int start, int end)
081:                    throws ConditionThrowable;
082:
083:            public abstract void shrink(int n) throws ConditionThrowable;
084:
085:            public int checkIndex(int index) throws ConditionThrowable {
086:                if (index < 0 || index >= capacity())
087:                    badIndex(index, capacity());
088:                return index;
089:            }
090:
091:            public int checkIndex(LispObject index) throws ConditionThrowable {
092:                int i = Fixnum.getValue(index);
093:                if (i < 0 || i >= capacity())
094:                    badIndex(i, capacity());
095:                return i;
096:            }
097:
098:            protected void badIndex(int index, int limit)
099:                    throws ConditionThrowable {
100:                StringBuffer sb = new StringBuffer("Invalid array index ");
101:                sb.append(index);
102:                sb.append(" for ");
103:                sb.append(writeToString());
104:                if (limit > 0) {
105:                    sb.append(" (should be >= 0 and < ");
106:                    sb.append(limit);
107:                    sb.append(").");
108:                }
109:                signal(new TypeError(sb.toString()));
110:            }
111:
112:            public void setFillPointer(int n) throws ConditionThrowable {
113:                noFillPointer();
114:            }
115:
116:            public void setFillPointer(LispObject obj)
117:                    throws ConditionThrowable {
118:                noFillPointer();
119:            }
120:
121:            public boolean isSimpleVector() {
122:                return false;
123:            }
124:
125:            public abstract LispObject reverse() throws ConditionThrowable;
126:
127:            public LispObject nreverse() throws ConditionThrowable {
128:                int i = 0;
129:                int j = length() - 1;
130:                while (i < j) {
131:                    LispObject temp = getRowMajor(i);
132:                    setRowMajor(i, getRowMajor(j));
133:                    setRowMajor(j, temp);
134:                    ++i;
135:                    --j;
136:                }
137:                return this ;
138:            }
139:
140:            public String writeToString() throws ConditionThrowable {
141:                if (_PRINT_READABLY_.symbolValue() != NIL) {
142:                    StringBuffer sb = new StringBuffer("#(");
143:                    final int limit = length();
144:                    for (int i = 0; i < limit; i++) {
145:                        if (i > 0)
146:                            sb.append(' ');
147:                        sb.append(getRowMajor(i).writeToString());
148:                    }
149:                    sb.append(')');
150:                    return sb.toString();
151:                } else if (_PRINT_ARRAY_.symbolValue() != NIL) {
152:                    StringBuffer sb = new StringBuffer("#(");
153:                    final LispObject printLength = _PRINT_LENGTH_.symbolValue();
154:                    final int limit;
155:                    if (printLength instanceof  Fixnum)
156:                        limit = Math
157:                                .min(length(), ((Fixnum) printLength).value);
158:                    else
159:                        limit = length();
160:                    for (int i = 0; i < limit; i++) {
161:                        if (i > 0)
162:                            sb.append(' ');
163:                        sb.append(getRowMajor(i).writeToString());
164:                    }
165:                    if (limit < length())
166:                        sb.append(limit > 0 ? " ..." : "...");
167:                    sb.append(')');
168:                    return sb.toString();
169:                } else {
170:                    StringBuffer sb = new StringBuffer();
171:                    sb.append(isSimpleVector() ? "SIMPLE-VECTOR " : "VECTOR ");
172:                    sb.append(capacity());
173:                    return unreadableString(sb.toString());
174:                }
175:            }
176:
177:            public abstract AbstractVector adjustVector(int size,
178:                    LispObject initialElement, LispObject initialContents)
179:                    throws ConditionThrowable;
180:
181:            public abstract AbstractVector adjustVector(int size,
182:                    AbstractArray displacedTo, int displacement)
183:                    throws ConditionThrowable;
184:
185:            public LispObject vectorPushExtend(LispObject element)
186:                    throws ConditionThrowable {
187:                return noFillPointer();
188:            }
189:
190:            public LispObject vectorPushExtend(LispObject element,
191:                    LispObject extension) throws ConditionThrowable {
192:                return noFillPointer();
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.