edu.olemiss.cs211
Class List<T>

java.lang.Object
  extended by edu.olemiss.cs211.List<T>
All Implemented Interfaces:
java.lang.Iterable<T>
Direct Known Subclasses:
OrderedList, Stack

public class List<T>
extends java.lang.Object
implements java.lang.Iterable<T>

A simple list class


Constructor Summary
List()
          Creates an empty list.
 
Method Summary
 void add(T o)
          Add the given object to the list.
 List<T> clone()
          Copies this list.
 T find(java.lang.Object k)
          Returns the object that is equal to the given key if it is found in the list.
 java.util.Iterator<T> iterator()
          Returns an iterator for this list.
static void main(java.lang.String[] args)
           
 int size()
          Return the number of elements in this list.
 java.lang.String toString()
          Write this list to a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

public List()
Creates an empty list.

Method Detail

add

public void add(T o)
Add the given object to the list.

Parameters:
o - the object to add.

toString

public java.lang.String toString()
Write this list to a string.

Overrides:
toString in class java.lang.Object
Returns:
a string representing this list.

size

public int size()
Return the number of elements in this list.

Returns:
the number of elements in this list.

iterator

public java.util.Iterator<T> iterator()
Returns an iterator for this list.

Specified by:
iterator in interface java.lang.Iterable<T>
Returns:
an iterator for this list.

clone

public List<T> clone()
Copies this list. However, it does not actually copy the data itself, just the ListNodes.

Overrides:
clone in class java.lang.Object
Returns:
a new list with references to the same data as this list.

find

public T find(java.lang.Object k)
Returns the object that is equal to the given key if it is found in the list. Otherwise, returns null. This implementation relies on the equals() method of the objects contained in the list.

Parameters:
k - an object that serves as a key.

main

public static void main(java.lang.String[] args)