Source Code Cross Referenced for AbstractIntCollection.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » pcj » 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 » rife 1.6.1 » com.uwyn.rife.pcj 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Primitive Collections for Java.
003:         *  Copyright (C) 2002, 2003  S�ren Bak
004:         *
005:         *  This library is free software; you can redistribute it and/or
006:         *  modify it under the terms of the GNU Lesser General Public
007:         *  License as published by the Free Software Foundation; either
008:         *  version 2.1 of the License, or (at your option) any later version.
009:         *
010:         *  This library is distributed in the hope that it will be useful,
011:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         *  Lesser General Public License for more details.
014:         *
015:         *  You should have received a copy of the GNU Lesser General Public
016:         *  License along with this library; if not, write to the Free Software
017:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:        package com.uwyn.rife.pcj;
020:
021:        import com.uwyn.rife.pcj.util.Exceptions;
022:
023:        /**
024:         *  This class represents an abstract base for implementing
025:         *  collections of int values. All operations that can be implemented
026:         *  using iterators are implemented as such. In most cases, this is
027:         *  hardly an efficient solution, and at least some of those
028:         *  methods should be overridden by sub-classes.
029:         *
030:         *  <p>In this implementation, <tt>size()</tt> is calculated by
031:         *  iterating over the collection. Make sure that <tt>size()</tt>
032:         *  is overwritten or that iterators do not depend on the
033:         *  <tt>size()</tt> method.
034:         *
035:         *  @author     S&oslash;ren Bak
036:         *  @version    1.3     21-08-2003 20:16
037:         *  @since      1.0
038:         */
039:        public abstract class AbstractIntCollection implements  IntCollection {
040:
041:            /** Default constructor to be invoked by sub-classes. */
042:            protected AbstractIntCollection() {
043:            }
044:
045:            /**
046:             *  Throws <tt>UnsupportedOperationException</tt>.
047:             *
048:             *  @throws     UnsupportedOperationException
049:             *              unconditionally.
050:             */
051:            public boolean add(int v) {
052:                Exceptions.unsupported("add");
053:                return false;
054:            }
055:
056:            public boolean addAll(IntCollection c) {
057:                IntIterator i = c.iterator(); //  Throws NullPointerException
058:                boolean result = false;
059:                while (i.hasNext())
060:                    result = result | add(i.next());
061:                return result;
062:            }
063:
064:            public void clear() {
065:                IntIterator i = iterator();
066:                while (i.hasNext()) {
067:                    i.next();
068:                    i.remove();
069:                }
070:            }
071:
072:            public boolean contains(int v) {
073:                IntIterator i = iterator();
074:                while (i.hasNext())
075:                    if (i.next() == v)
076:                        return true;
077:                return false;
078:            }
079:
080:            public boolean containsAll(IntCollection c) {
081:                IntIterator i = c.iterator(); //  Throws NullPointerException
082:                while (i.hasNext())
083:                    if (!contains(i.next()))
084:                        return false;
085:                return true;
086:            }
087:
088:            public boolean isEmpty() {
089:                return size() == 0;
090:            }
091:
092:            public boolean remove(int v) {
093:                IntIterator i = iterator();
094:                boolean result = false;
095:                while (i.hasNext()) {
096:                    if (i.next() == v) {
097:                        i.remove();
098:                        result = true;
099:                        break;
100:                    }
101:                }
102:                return result;
103:            }
104:
105:            public boolean removeAll(IntCollection c) {
106:                if (c == null)
107:                    Exceptions.nullArgument("collection");
108:                IntIterator i = iterator();
109:                boolean result = false;
110:                while (i.hasNext()) {
111:                    if (c.contains(i.next())) {
112:                        i.remove();
113:                        result = true;
114:                    }
115:                }
116:                return result;
117:            }
118:
119:            public boolean retainAll(IntCollection c) {
120:                if (c == null)
121:                    Exceptions.nullArgument("collection");
122:                IntIterator i = iterator();
123:                boolean result = false;
124:                while (i.hasNext()) {
125:                    if (!c.contains(i.next())) {
126:                        i.remove();
127:                        result = true;
128:                    }
129:                }
130:                return result;
131:            }
132:
133:            public int size() {
134:                IntIterator i = iterator();
135:                int size = 0;
136:                while (i.hasNext()) {
137:                    i.next();
138:                    size++;
139:                }
140:                return size;
141:            }
142:
143:            public int[] toArray() {
144:                return toArray(null);
145:            }
146:
147:            public int[] toArray(int[] a) {
148:                int size = size();
149:                if (a == null || a.length < size)
150:                    a = new int[size];
151:                IntIterator i = iterator();
152:                int index = 0;
153:                while (i.hasNext()) {
154:                    a[index] = i.next();
155:                    index++;
156:                }
157:                return a;
158:            }
159:
160:            /**
161:             *  Does nothing. Sub-classes may provide an implementation to
162:             *  minimize memory usage, but this is not required since many
163:             *  implementations will always have minimal memory usage.
164:             */
165:            public void trimToSize() {
166:            }
167:
168:            /**
169:             *  Returns a string representation of this collection.
170:             *
171:             *  @return     a string representation of this collection.
172:             */
173:            public String toString() {
174:                StringBuffer s = new StringBuffer();
175:                s.append('[');
176:                IntIterator i = iterator();
177:                while (i.hasNext()) {
178:                    if (s.length() > 1)
179:                        s.append(',');
180:                    s.append(com.uwyn.rife.pcj.util.Display.display(i.next()));
181:                }
182:                s.append(']');
183:                return s.toString();
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.