All Packages Class Hierarchy This Package Previous Next Index
Class list.List
java.lang.Object
|
+----list.List
- public class List
- extends Object
The List class implements a linked list abstraction. Lists
are mutable data structures, which can grow at either end.
- Author:
- Kathy Yelick
-
List()
- Construct an empty list
-
elements()
- Returns an Enumeration of the components of this list.
-
insertEnd(Object)
- Inserts obj into this list at the end.
-
insertFront(Object)
- Inserts obj into this list at the beginning.
-
isEmpty()
- Returns true if this list is empty,
false otherwise.
-
length()
- Returns the length of this list.
-
main(String[])
- Runs test cases on the the List class.
-
nth(int)
- Returns the element at the specified position.
-
toString()
- Returns a String representation of the list.
List
public List()
- Construct an empty list
isEmpty
public boolean isEmpty()
- Returns true if this list is empty,
false otherwise.
- Returns:
- true if the list is empty, false otherwise.
length
public int length()
- Returns the length of this list.
- Returns:
- the length of the list.
insertFront
public void insertFront(Object obj)
- Inserts obj into this list at the beginning.
- Parameters:
- obj - the object to be inserted.
insertEnd
public void insertEnd(Object obj)
- Inserts obj into this list at the end.
- Parameters:
- obj - the object to be inserted.
nth
public Object nth(int position)
- Returns the element at the specified position.
If position < 1 or position > length(),
then null is returned. Otherwise, the item at
position is returned. The list is unchanged in either
case.
- Parameters:
- position - the desired position in the list (between
1 and length()).
- Returns:
- the Object at the given position in the List.
elements
public Enumeration elements()
- Returns an Enumeration of the components of this list.
- Returns:
- an Enumeration of the components of this list.
toString
public String toString()
- Returns a String representation of the list.
- Returns:
- a String representation of the list.
- Overrides:
- toString in class Object
main
public static void main(String argv[])
- Runs test cases on the the List class.
Prints summary information on basic operations and halts
with an error (and a stack trace) if any of the tests fail.
All Packages Class Hierarchy This Package Previous Next Index