public class SharedStack<T> extends java.lang.Object implements ISharedStack<T>
Constructor and Description |
---|
SharedStack()
Default constructor.
|
SharedStack(java.lang.Class<?> genericTypeParameter)
Constructor for initializing with the generic type parameter
|
SharedStack(java.lang.Iterable<? extends T> iterable)
Constructor initializes with an initial collection and this class's generic type parameter
|
SharedStack(java.lang.Iterable<? extends T> iterable,
java.lang.Class<?> genericTypeParameter)
Constructor initializes with an initial collection and this class's generic type parameter
|
SharedStack(ReifiedIterable<T> iterable)
Constructor initializes from another reified collection
|
SharedStack(T[] array)
Initializes with an array.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the stack.
|
T |
get()
Pops an object, blocking if none is available
|
java.lang.Class<?> |
getGenericTypeParameter()
Returns the class generic type parameters.
|
java.lang.Iterable<T> |
getRange(int count)
Dequeues a number of objects, blocking if not all are available.
|
java.util.Iterator<T> |
iterator()
Returns an iterator of a copy of the collection.
|
void |
lock()
Locks the collection
|
T |
peek()
Returns the next element without removing it.
|
void |
put(T item)
Pushes an object in the stack.
|
void |
putRange(java.lang.Iterable<? extends T> items)
Pushes a number of objects.
|
int |
size()
Returns the queue length.
|
T[] |
toArray()
Puts all elements in an array and returns them.
|
ReifiedList<T> |
toList()
Puts all elements in a list and returns them.
|
java.lang.String |
toString() |
void |
unlock()
Unlocks the collection
|
public SharedStack()
SuperTypeTokenException
- When called without using anonymous class semantics.public SharedStack(java.lang.Class<?> genericTypeParameter)
java.lang.NullPointerException
- When the generic type parameter is null.public SharedStack(ReifiedIterable<T> iterable)
java.lang.NullPointerException
- When the argument is nullpublic SharedStack(java.lang.Iterable<? extends T> iterable)
java.lang.NullPointerException
- When the argument is nullSuperTypeTokenException
- When called without using anonymous class semantics.public SharedStack(java.lang.Iterable<? extends T> iterable, java.lang.Class<?> genericTypeParameter)
java.lang.NullPointerException
- When an argument is nullpublic SharedStack(T[] array)
java.lang.NullPointerException
- When the argument is nullpublic void clear()
clear
in interface ISharedStack<T>
public T get()
get
in interface ISharedStack<T>
public java.lang.Iterable<T> getRange(int count)
getRange
in interface ISharedStack<T>
java.lang.IllegalArgumentException
- When the argument is out of rangepublic java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public java.lang.Class<?> getGenericTypeParameter()
getGenericTypeParameter
in interface ReifiedIterable<T>
public T peek()
peek
in interface ISharedStack<T>
java.util.NoSuchElementException
- When the stack is emptypublic void put(T item)
put
in interface ISharedStack<T>
public void putRange(java.lang.Iterable<? extends T> items)
putRange
in interface ISharedStack<T>
java.lang.NullPointerException
- When the items argument is null.public int size()
size
in interface ISharedStack<T>
public T[] toArray()
toArray
in interface ISharedStack<T>
public ReifiedList<T> toList()
toList
in interface ISharedStack<T>
public void unlock()
public java.lang.String toString()
toString
in class java.lang.Object