class LStack<E> implements Stack<E> {
private Link<E> top;
private int size;
LStack() { top = null; size = 0; }
LStack(int size) { top = null; size = 0; }
public void clear() { top = null; size = 0; }
public boolean push(E it) {
top = new Link<E>(it, top);
size++;
return true;
}
public E pop() {
if (top == null) { return null; }
E it = top.element();
top = top.next();
size--;
return it;
}
public E topValue() {
if (top == null) { return null; }
return top.element();
}
public int length() { return size; }
public boolean isEmpty() { return size == 0; }
}