Package com.adobe.internal.util
Class ArrayListStack<T>
java.lang.Object
com.adobe.internal.util.ArrayListStack<T>
- All Implemented Interfaces:
Stack<T>
,Serializable
,Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty stack.ArrayListStack
(int size) Constructs an empty stack of the size given.ArrayListStack
(ArrayList<T> list) Constructs the stack from the ArrayList provided. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends T> collection) boolean
addAll
(Collection<? extends T> collection) void
clear()
boolean
boolean
containsAll
(Collection<?> collection) boolean
empty()
Tests if stack is empty.boolean
Compares the specified object with this list for equality.get
(int index) returns the underlying ArrayListint
hashCode()
Returns the hash code value for this list.int
boolean
isEmpty()
iterator()
int
listIterator
(int index) peek()
Returns item from the top of the stack.pop()
Removes and returns item from the top of the stack.Adds an item to the top of the stack.remove
(int index) boolean
boolean
removeAll
(Collection<?> collection) boolean
retainAll
(Collection<?> collection) int
Returns the 1-based position where an object is on this stack.int
size()
Returns the size of the stack.subList
(int fromIndex, int toIndex) Object[]
toArray()
Object[]
toString()
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Constructor Details
-
ArrayListStack
public ArrayListStack()Constructs an empty stack. -
ArrayListStack
public ArrayListStack(int size) Constructs an empty stack of the size given. -
ArrayListStack
Constructs the stack from the ArrayList provided.
-
-
Method Details
-
getArrayList
returns the underlying ArrayList -
push
Adds an item to the top of the stack. -
pop
Removes and returns item from the top of the stack.- Specified by:
pop
in interfaceStack<T>
- Returns:
- the former top item.
- Throws:
EmptyStackException
- if stack is empty.
-
peek
Returns item from the top of the stack.- Specified by:
peek
in interfaceStack<T>
- Returns:
- the top item.
- Throws:
EmptyStackException
- if stack is empty.
-
empty
public boolean empty()Tests if stack is empty. -
size
public int size()Returns the size of the stack. -
clear
public void clear() -
toString
-
equals
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order.This implementation first checks if the specified object is this list. If so, it returns true; if not, it checks if the specified object is a list. If not, it returns false; if so, it iterates over both lists, comparing corresponding pairs of elements. If any comparison returns false, this method returns false. If either iterator runs out of elements before the other it returns false (as the lists are of unequal length); otherwise it returns true when the iterations complete.
-
hashCode
public int hashCode()Returns the hash code value for this list.This implementation uses exactly the code that is used to define the list hash function in the documentation for the List.hashCode method.
-
search
Returns the 1-based position where an object is on this stack. If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1. The equals method is used to compare o to the items in this stack.- Parameters:
o
- the desired object.- Returns:
- the 1-based position from the top of the stack where
the object is located; the return value
-1
indicates that the object is not on the stack.
-
add
-
add
-
addAll
-
addAll
-
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceList<T>
-
get
-
indexOf
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
subList
-
toArray
-
toArray
-