Package com.helger.commons.collection
Class NonBlockingStack<ELEMENTTYPE>
java.lang.Object
java.util.AbstractCollection<ELEMENTTYPE>
java.util.AbstractList<ELEMENTTYPE>
java.util.ArrayList<ELEMENTTYPE>
com.helger.commons.collection.impl.CommonsArrayList<ELEMENTTYPE>
com.helger.commons.collection.NonBlockingStack<ELEMENTTYPE>
- Type Parameters:
ELEMENTTYPE- The type of the elements contained in the stack
- All Implemented Interfaces:
ICommonsCollection<ELEMENTTYPE>,ICommonsIterable<ELEMENTTYPE>,ICommonsList<ELEMENTTYPE>,ICloneable<ICommonsList<ELEMENTTYPE>>,IHasSize,Serializable,Cloneable,Iterable<ELEMENTTYPE>,Collection<ELEMENTTYPE>,List<ELEMENTTYPE>,RandomAccess,SequencedCollection<ELEMENTTYPE>
A version of a stack that does not use
Vector but an
CommonsArrayList as the underlying data structure as opposed to
Stack. This spares us from unnecessary synchronization.- Author:
- Philip Helger
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionNonBlockingStack(int nInitialCapacity) NonBlockingStack(NonBlockingStack<? extends ELEMENTTYPE> aStack) NonBlockingStack(ELEMENTTYPE... aElements) NonBlockingStack(Collection<? extends ELEMENTTYPE> aCollection) -
Method Summary
Modifier and TypeMethodDescriptionbooleangetClone()inthashCode()peek()Looks at the object at the top of this stack without removing it from the stack.pop()Removes the object at the top of this stack and returns that object as the value of this function.push(ELEMENTTYPE aItem) Pushes an item onto the top of this stack.replaceTopElement(ELEMENTTYPE aItem) Replaces the top element in the stack.top()Looks at the object at the top of this stack without removing it from the stack.toString()Methods inherited from class com.helger.commons.collection.impl.CommonsArrayList
createFiltered, createFiltered, createFiltered, createFiltered, createFiltered, createFiltered, createInstanceMethods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, forEach, get, getFirst, getLast, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.helger.commons.collection.impl.ICommonsCollection
addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addIf, addIfNotNull, addObject, getAtIndex, getAtIndex, getAtIndex, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getCopyAsList, getCount, getSorted, iterator2, removeAll, removeObject, set, setAll, setAll, setAllMapped, setAllMappedMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCountMethods inherited from interface com.helger.commons.collection.impl.ICommonsList
getAll, getAllInstanceOf, getAllMapped, getAllMapped, getAsUnmodifiable, getAtIndex, getFirst, getFirst, getFirstOrNull, getLast, getLast, getLastOrNull, getSortedInline, removeAndReturnElementAtIndex, removeAtIndex, removeFirst, removeFirstOrNull, removeLast, removeLastOrNull, reverse, setFirst, setLast, swapItemsMethods inherited from interface com.helger.commons.lang.IHasSize
isEmpty, isNotEmpty, sizeMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
NonBlockingStack
public NonBlockingStack() -
NonBlockingStack
-
NonBlockingStack
-
NonBlockingStack
-
NonBlockingStack
-
-
Method Details
-
push
Pushes an item onto the top of this stack.- Parameters:
aItem- the item to be pushed onto this stack.- Returns:
- the
aItemargument.
-
pop
Removes the object at the top of this stack and returns that object as the value of this function.- Returns:
- The object at the top of this stack (the last item of the list).
- Throws:
EmptyStackException- if this stack is empty.
-
peek
Looks at the object at the top of this stack without removing it from the stack.- Returns:
- the object at the top of this stack (the last item of the list).
- Throws:
EmptyStackException- if this stack is empty.
-
top
Looks at the object at the top of this stack without removing it from the stack. Synonym forpeek()- Returns:
- the object at the top of this stack (the last item of the list).
- Throws:
EmptyStackException- if this stack is empty.- See Also:
-
firstElement
- Returns:
- The first element in the stack (the oldest element) in comparison
to
peek()delivering the last element. - Throws:
EmptyStackException- if the stack is empty
-
replaceTopElement
Replaces the top element in the stack. This is a shortcut forpop (); push (aItem);- Parameters:
aItem- the item to be pushed onto this stack.- Returns:
- the
aItemargument. - Throws:
EmptyStackException- if the stack is empty
-
getClone
- Specified by:
getClonein interfaceICloneable<ELEMENTTYPE>- Overrides:
getClonein classCommonsArrayList<ELEMENTTYPE>- Returns:
- A 100% deep-copy of the implementing class.
-
equals
- Specified by:
equalsin interfaceCollection<ELEMENTTYPE>- Specified by:
equalsin interfaceList<ELEMENTTYPE>- Overrides:
equalsin classArrayList<ELEMENTTYPE>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<ELEMENTTYPE>- Specified by:
hashCodein interfaceList<ELEMENTTYPE>- Overrides:
hashCodein classArrayList<ELEMENTTYPE>
-
toString
- Overrides:
toStringin classAbstractCollection<ELEMENTTYPE>
-