Source Code Cross Referenced for doubleVector.java in  » Web-Framework » RSF » uk » org » ponder » doubleutil » 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
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » RSF » uk.org.ponder.doubleutil 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package uk.org.ponder.doubleutil;
002:
003:        /** A simple container class representing a vector of native integers.
004:         */
005:
006:        public class doubleVector {
007:            private double[] doubles;
008:            private int size;
009:
010:            public class doubleVectorIterator implements  doubleIterator {
011:                int index = 0;
012:
013:                public boolean hasNextDouble() {
014:                    return index != size;
015:                }
016:
017:                public void next() {
018:                    ++index;
019:                }
020:
021:                public void setDouble(double toset) {
022:                    doubles[index] = toset;
023:                }
024:
025:                public double getDouble() {
026:                    return doubles[index];
027:                }
028:            }
029:
030:            public doubleIterator beginIterator() {
031:                return new doubleVectorIterator();
032:            }
033:
034:            /** Constructs an intVector with the specified initial capacity.
035:             * @param initalcapacity The required initial capacity.
036:             */
037:            public doubleVector(int initialcapacity) {
038:                doubles = new double[initialcapacity];
039:                size = 0;
040:            }
041:
042:            public void ensureIndex(int i) {
043:                if (i >= size) {
044:                    setSize(i + 1);
045:                }
046:            }
047:
048:            /** Returns the integer at the specified index.
049:             * @param i The index of the required integer.
050:             * @return The integer at index <code>i</code>
051:             */
052:            public double doubleAt(int i) {
053:                return doubles[i];
054:            }
055:
056:            public double doubleAtSafe(int i) {
057:                ensureIndex(i);
058:                return doubleAt(i);
059:            }
060:
061:            /** Assigns a value to a member of the vector.
062:             * @param i the index to assign a value at.
063:             * @param value the value to assign.
064:             */
065:
066:            public void setDoubleAt(int i, double value) {
067:                doubles[i] = value;
068:            }
069:
070:            public void setDoubleAtSafe(int i, double value) {
071:                ensureIndex(i);
072:                setDoubleAt(i, value);
073:            }
074:
075:            /** Returns the current size of this vector.
076:             * @return the current size of this vector.
077:             */
078:            public int size() {
079:                return size;
080:            }
081:
082:            /** Sets the new size of this vector. 
083:             * @param newsize The new size of the vector.
084:             */
085:
086:            public void setSize(int newsize) {
087:                if (newsize > doubles.length)
088:                    reallocate(newsize + doubles.length);
089:                size = newsize;
090:            }
091:
092:            private void reallocate(int newsize) {
093:                double[] newdoubles = new double[newsize];
094:                System.arraycopy(doubles, 0, newdoubles, 0, size);
095:                doubles = newdoubles;
096:            }
097:
098:            /** Appends a new element to the end of this vector, reallocating its storage space if necessary.
099:             * @param i The integer value to be appended to the vector.
100:             */
101:            public void addElement(double i) {
102:                if (size == doubles.length) {
103:                    reallocate(doubles.length * 2);
104:                }
105:                doubles[size] = i;
106:                ++size;
107:            }
108:
109:            /** Removes the element at the specified index.
110:             * @param i The index of the element to be removed from this vector.
111:             */
112:            public void removeElementAt(int i) {
113:                System.arraycopy(doubles, i + 1, doubles, i, size - (i + 1));
114:                --size;
115:            }
116:
117:            /** Removes and returns the final element of the vector.
118:             * @return The value of the final element of the vector, which was removed.
119:             */
120:            public double popElement() {
121:                return doubles[--size];
122:            }
123:
124:            /** Returns the final element of the vector.
125:             * @return The value of the final element of the vector.
126:             */
127:
128:            public double peek() {
129:                return doubles[size - 1];
130:            }
131:
132:            /** Sets this vector to zero size, effectively removing all its elements.
133:             */
134:            public void clear() {
135:                size = 0;
136:            }
137:
138:            /** Determines whether this vector is empty.
139:             * @return <code>true</code> if this vector is empty.
140:             */
141:            public boolean isEmpty() {
142:                return size == 0;
143:            }
144:
145:            /** Assigns to this intVector the contents of another, overwriting our contents.
146:             * @param other The intVector to assign to us.
147:             */
148:
149:            public void assign(doubleVector other) {
150:                doubles = new double[other.doubles.length];
151:                System.arraycopy(other.doubles, 0, doubles, 0, doubles.length);
152:                size = other.size;
153:            }
154:
155:            /** Renders this intVector as a String for debugging purposes.
156:             * @return the contents of this intVector as a debug string.
157:             */
158:
159:            public String toString() {
160:                StringBuffer togo = new StringBuffer();
161:                for (int i = 0; i < size - 1; ++i) {
162:                    togo.append(doubles[i]).append(' ');
163:                }
164:                togo.append(doubles[size - 1]);
165:                return togo.toString();
166:            }
167:
168:            /** Returns the contents of this doubleVector as an array of doubles.
169:             * @return A double array with the contents of this doubleVector.
170:             */
171:            public double[] asArray() {
172:                double[] togo = new double[size];
173:                System.arraycopy(doubles, 0, togo, 0, size);
174:                return togo;
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.