Methods Summary |
---|
public final boolean | empty()
// Tests if this stack is empty.
return top == -1;
|
private void | ensure()
if (top == (data.length-1)) {
int newSize = 2*data.length ;
Object[] newData = new Object[ newSize ] ;
System.arraycopy( data, 0, newData, 0, data.length ) ;
data = newData ;
}
|
public final java.lang.Object | peek()
if (empty())
throw new EmptyStackException();
return data[ top ];
|
public final java.lang.Object | pop()
Object obj = peek() ;
data[top] = null ;
top-- ;
return obj;
|
public final java.lang.Object | push(java.lang.Object item)
ensure() ;
top++ ;
data[top] = item;
return item;
|