Methods Summary |
---|
public void | add(java.lang.Object o)Add an object to the end of the list.
append(o);
|
public void | append(java.lang.Object o)Append an object to the end of the list.
LLCell n = new LLCell(o);
if (length == 0) {
head = tail = n;
length = 1;
}
else {
tail.next = n;
tail = n;
length++;
}
|
protected java.lang.Object | deleteHead()Delete the object at the head of the list.
if (head == null) throw new NoSuchElementException();
Object o = head.data;
head = head.next;
length--;
return o;
|
public java.lang.Object | elementAt(int i)Get the ith element in the list.
int j = 0;
for (LLCell p = head; p != null; p = p.next) {
if (i == j) return p.data;
j++;
}
throw new NoSuchElementException();
|
public java.util.Enumeration | elements()Return an enumeration of the list elements
return new LLEnumeration(this);
|
public int | height()How high is the stack?
return length;
|
public boolean | includes(java.lang.Object o)Answers whether or not an object is contained in the list
for (LLCell p = head; p != null; p = p.next) {
if (p.data.equals(o)) return true;
}
return false;
|
protected void | insertHead(java.lang.Object o)Insert an object at the head of the list.
LLCell c = head;
head = new LLCell(o);
head.next = c;
length++;
if (tail == null) tail = head;
|
public int | length()Return the length of the list.
return length;
|
public java.lang.Object | pop()Pop the top element of the stack off.
Object o = deleteHead();
return o;
|
public void | push(java.lang.Object o)Push an object onto the stack.
insertHead(o);
|
public java.lang.Object | top()
if (head == null) throw new NoSuchElementException();
return head.data;
|