|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object
|
+--com.sosnoski.util.GrowableBase
|
+--com.sosnoski.util.stack.StackBase
Base class for type-specific stack classes with any type of values
(including primitive types). This class builds on the basic structure
provided by GrowableBase, specializing it for usage as a
stack. See the base class description for details of the implementation.
Stacks based on this class are unsynchronized in order to provide the best possible performance for typical usage scenarios, so explicit synchronization must be implemented by the subclass or the application in cases where they are to be modified in a multithreaded environment.
Subclasses need to implement the abstract methods defined by the base class
for working with the data array, as well as the actual data access methods
(at least the basic push(), pop(), and
peek() methods).
| Field Summary | |
protected int |
m_countPresent
The number of values currently present in the stack. |
| Fields inherited from class com.sosnoski.util.GrowableBase |
DEFAULT_SIZE, m_countLimit, m_maximumGrowth |
| Constructor Summary | |
StackBase(int size,
java.lang.Class type)
Constructor with partial specification. |
|
StackBase(int size,
int growth,
java.lang.Class type)
Constructor with full specification. |
|
StackBase(StackBase base)
Copy (clone) constructor. |
|
| Method Summary | |
protected java.lang.Object |
buildArray(java.lang.Class type)
Constructs and returns a simple array containing the same data as held in this stack. |
void |
clear()
Set the stack to the empty state. |
protected int |
getAddIndex()
Gets the array offset for appending a value to those in the stack. |
boolean |
isEmpty()
Check if stack is empty. |
int |
size()
Get the number of values currently present in the stack. |
| Methods inherited from class com.sosnoski.util.GrowableBase |
buildArray, discardValues, ensureCapacity, getArray, growArray, resizeCopy, setArray |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int m_countPresent
| Constructor Detail |
public StackBase(int size,
int growth,
java.lang.Class type)
size - number of elements initially allowed in stackgrowth - maximum size increment for growing stacktype - stack element type
public StackBase(int size,
java.lang.Class type)
size - number of elements initially allowed in stacktype - stack element typepublic StackBase(StackBase base)
base - instance being copied| Method Detail |
protected int getAddIndex()
public int size()
public boolean isEmpty()
true if stack empty, false if notpublic void clear()
protected java.lang.Object buildArray(java.lang.Class type)
type - element type for constructed array
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||