Methods Summary |
---|
public java.lang.Object | clone()Returns clone of current ObjectStack
return (ObjectStack) super.clone();
|
public boolean | empty()Tests if this stack is empty.
return m_firstFree == 0;
|
public java.lang.Object | peek()Looks at the object at the top of this stack without removing it
from the stack.
try {
return m_map[m_firstFree - 1];
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new EmptyStackException();
}
|
public java.lang.Object | peek(int n)Looks at the object at the position the stack counting down n items.
try {
return m_map[m_firstFree-(1+n)];
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new EmptyStackException();
}
|
public java.lang.Object | pop()Removes the object at the top of this stack and returns that
object as the value of this function.
Object val = m_map[--m_firstFree];
m_map[m_firstFree] = null;
return val;
|
public java.lang.Object | push(java.lang.Object i)Pushes an item onto the top of this stack.
if ((m_firstFree + 1) >= m_mapSize)
{
m_mapSize += m_blocksize;
Object newMap[] = new Object[m_mapSize];
System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
m_map = newMap;
}
m_map[m_firstFree] = i;
m_firstFree++;
return i;
|
public void | quickPop(int n)Quickly pops a number of items from the stack.
m_firstFree -= n;
|
public int | search(java.lang.Object o)Returns where an object is on this stack.
int i = lastIndexOf(o);
if (i >= 0)
{
return size() - i;
}
return -1;
|
public void | setTop(java.lang.Object val)Sets an object at a the top of the statck
try {
m_map[m_firstFree - 1] = val;
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new EmptyStackException();
}
|