Source Code Cross Referenced for ArrayListStack.java in  » J2EE » wicket » wicket » util » collections » 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 » J2EE » wicket » wicket.util.collections 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ArrayListStack.java 459319 2006-02-14 20:54:57Z jonl $
003:         * $Revision: 459319 $ $Date: 2006-02-14 21:54:57 +0100 (Tue, 14 Feb 2006) $
004:         * 
005:         * ==============================================================================
006:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007:         * use this file except in compliance with the License. You may obtain a copy of
008:         * the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015:         * License for the specific language governing permissions and limitations under
016:         * the License.
017:         */
018:        package wicket.util.collections;
019:
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.EmptyStackException;
023:
024:        /**
025:         * A faster, smaller stack implementation. ArrayListStack is final and
026:         * unsynchronized (the JDK's methods are synchronized). In addition you can set
027:         * the initial capacity if you want via the ArrayListStack(int) constructor.
028:         * 
029:         * @author Jonathan Locke
030:         */
031:        public final class ArrayListStack extends ArrayList {
032:            private static final long serialVersionUID = 1L;
033:
034:            /**
035:             * Construct.
036:             * 
037:             * @param initialCapacity
038:             *            Initial capacity of the stack
039:             */
040:            public ArrayListStack(final int initialCapacity) {
041:                super (initialCapacity);
042:            }
043:
044:            /**
045:             * Construct.
046:             */
047:            public ArrayListStack() {
048:                this (10);
049:            }
050:
051:            /**
052:             * Construct.
053:             * 
054:             * @param collection
055:             *            The collection to add
056:             */
057:            public ArrayListStack(final Collection collection) {
058:                super (collection);
059:            }
060:
061:            /**
062:             * Pushes an item onto the top of this stack.
063:             * 
064:             * @param item
065:             *            the item to be pushed onto this stack.
066:             */
067:            public final void push(final Object item) {
068:                add(item);
069:            }
070:
071:            /**
072:             * Removes the object at the top of this stack and returns that object.
073:             * 
074:             * @return The object at the top of this stack
075:             * @exception EmptyStackException
076:             *                If this stack is empty.
077:             */
078:            public final Object pop() {
079:                final Object top = peek();
080:                remove(size() - 1);
081:                return top;
082:            }
083:
084:            /**
085:             * Looks at the object at the top of this stack without removing it.
086:             * 
087:             * @return The object at the top of this stack
088:             * @exception EmptyStackException
089:             *                If this stack is empty.
090:             */
091:            public final Object peek() {
092:                int size = size();
093:                if (size == 0) {
094:                    throw new EmptyStackException();
095:                }
096:                return get(size - 1);
097:            }
098:
099:            /**
100:             * Tests if this stack is empty.
101:             * 
102:             * @return <code>true</code> if and only if this stack contains no items;
103:             *         <code>false</code> otherwise.
104:             */
105:            public final boolean empty() {
106:                return size() == 0;
107:            }
108:
109:            /**
110:             * Returns the 1-based position where an object is on this stack. If the
111:             * object <tt>o</tt> occurs as an item in this stack, this method returns
112:             * the distance from the top of the stack of the occurrence nearest the top
113:             * of the stack; the topmost item on the stack is considered to be at
114:             * distance <tt>1</tt>. The <tt>equals</tt> method is used to compare
115:             * <tt>o</tt> to the items in this stack.
116:             * 
117:             * @param o
118:             *            the desired object.
119:             * @return the 1-based position from the top of the stack where the object
120:             *         is located; the return value <code>-1</code> indicates that the
121:             *         object is not on the stack.
122:             */
123:            public final int search(final Object o) {
124:                int i = lastIndexOf(o);
125:                if (i >= 0) {
126:                    return size() - i;
127:                }
128:                return -1;
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.