FileDocCategorySizeDatePackage
LinkList.javaAPI DocExample3622Sun Feb 29 12:50:20 GMT 2004None

LinkList

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

		super();
		clear();
	
public LinkList(Collection c)
Construct a LinkList given another Collection. This method is recommended by the general contract of List.

		this();
		addAll(c);
		throw new IllegalArgumentException("Can't construct(Collection) yet");
	
Methods Summary
public booleanadd(java.lang.Object o)
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;
	
public voidadd(int where, java.lang.Object o)

		TNode t = first;
		for (int i=0; i<where; i++)
			t = t.next;
		TNode t2 = t;
		t.next = new TNode(o);
		t.next = t2;
	
public booleanaddAll(java.util.Collection c)

		return false;
	
public booleanaddAll(int i, java.util.Collection c)

		return false;
	
public voidclear()
Set the List (back) to its initial state. Any references held will be discarded.

		first = new TNode(this);
		last = first;
	
public booleancontains(java.lang.Object o)

		return false;
	
public booleancontainsAll(java.util.Collection c)

		return false;
	
public java.lang.Objectget(int where)

		TNode t = first;
		for (int i=0; i<where; i++) {
			t = t.next;
		}
		return t.data;
	
public intindexOf(java.lang.Object o)

		return 0;
	
public booleanisEmpty()

		return size() == 0;
	
public java.util.Iteratoriterator()

		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");
			}
		};
	
public intlastIndexOf(java.lang.Object o)

		return 0;
	
public java.util.ListIteratorlistIterator()

		throw new UnsupportedOperationException("listIterator");
	
public java.util.ListIteratorlistIterator(int where)

		return null;
	
public booleanlookup(java.lang.Object o)

		for (TNode p=first.next; p != null; p = p.next)
			if (p.data==o || p.data.equals(o))
				return true;
		return false;
	
public booleanremove(java.lang.Object o)

		return false;
	
public java.lang.Objectremove(int i)

		return null;
	
public booleanremoveAll(java.util.Collection c)

		return false;
	
public booleanretainAll(java.util.Collection c)

		return false;
	
public java.lang.Objectset(int i, java.lang.Object o)

		return null;
	
public intsize()

		TNode t = first;
		int i;
		for (i=0; ; i++) {
			if (t == null)
				break;
			t = t.next;
		}
		return i - 1;	// subtract one for mandatory head node.
	
public java.util.ListsubList(int sub1, int sub2)

		return null;
	
public java.lang.Object[]toArray()

		return null;
	
public java.lang.Object[]toArray(java.lang.Object[] data)

		return null;