public class LinkList extends Object implements List
Linked list class, written in Java.
This is not intended to be a usable List, and it is certainly
not going to be optimal in terms of performance; it is just
here to remind you how much work the existing List implementations do.
TODO: scrap this and start again, subclassing AbstractSequentialList
deprecated
Supplanted by LinkedList
author
Ian Darwin
Fields Summary
protected TNode
first
The root or first TNode in the list.
protected TNode
last
The last TNode in the list
Constructors Summary
public LinkList()
Construct a LinkList: initialize the first and last nodes
Add one object to the end of the list. Update the "next"
reference in the previous end, to refer to the new node.
Update "last" to refer to the new node.
last.next = new TNode(o);
last = last.next;
return true;
return new Iterator() {
TNode t = first;
int i = 0;
public boolean hasNext() {
return t != last;
}
public Object next() {
if (t == last)
throw new ArrayIndexOutOfBoundsException();
return t = t.next;
}
public void remove() {
throw new UnsupportedOperationException("remove");
}
};