public class ArrayListStack<T> extends Object implements Stack<T>, List<T>, Serializable
| Constructor and Description |
|---|
ArrayListStack()
Constructs an empty stack.
|
ArrayListStack(ArrayList<T> list)
Constructs the stack from the ArrayList provided.
|
ArrayListStack(int size)
Constructs an empty stack of the size given.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element) |
boolean |
add(T element) |
boolean |
addAll(Collection<? extends T> collection) |
boolean |
addAll(int index,
Collection<? extends T> collection) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> collection) |
boolean |
empty()
Tests if stack is empty.
|
boolean |
equals(Object obj)
Compares the specified object with this list for equality.
|
T |
get(int index) |
ArrayList<T> |
getArrayList()
returns the underlying ArrayList
|
int |
hashCode()
Returns the hash code value for this list.
|
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<T> |
listIterator() |
ListIterator<T> |
listIterator(int index) |
T |
peek()
Returns item from the top of the stack.
|
T |
pop()
Removes and returns item from the top of the stack.
|
T |
push(T elem)
Adds an item to the top of the stack.
|
T |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> collection) |
boolean |
retainAll(Collection<?> collection) |
int |
search(T o)
Returns the 1-based position where an object is on this stack.
|
T |
set(int index,
T element) |
int |
size()
Returns the size of the stack.
|
List<T> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
Object[] |
toArray(Object[] a) |
String |
toString() |
replaceAll, sort, spliteratorparallelStream, removeIf, streampublic ArrayListStack()
public ArrayListStack(int size)
public T pop() throws EmptyStackException
pop in interface Stack<T>EmptyStackException - if stack is empty.public T peek() throws EmptyStackException
peek in interface Stack<T>EmptyStackException - if stack is empty.public boolean empty()
public int size()
public void clear()
public boolean equals(Object obj)
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.
public int hashCode()
This implementation uses exactly the code that is used to define the list hash function in the documentation for the List.hashCode method.
public int search(T o)
o - the desired object.-1
indicates that the object is not on the stack.public boolean add(T element)
public boolean addAll(Collection<? extends T> collection)
public boolean addAll(int index,
Collection<? extends T> collection)
public boolean contains(Object o)
public boolean containsAll(Collection<?> collection)
containsAll in interface Collection<T>containsAll in interface List<T>public boolean isEmpty()
public int lastIndexOf(Object o)
lastIndexOf in interface List<T>public ListIterator<T> listIterator()
listIterator in interface List<T>public ListIterator<T> listIterator(int index)
listIterator in interface List<T>public boolean remove(Object o)
public boolean removeAll(Collection<?> collection)
public boolean retainAll(Collection<?> collection)
public Object[] toArray()
Copyright © 2010 - 2020 Adobe. All Rights Reserved