Class LinkedList
java.lang.Object
|
+----LinkedList
- public class LinkedList
- extends Object
NetRand Project
Software Engineering - CS536
University of Wisconsin - Milwaukee
Authors:
- Spring 1998 - Francis William Kasper
File: LinkedList.java
LinkedList Class: implements the a linked-list data structure.
-
head
-
-
len
-
-
pre
-
-
tail
-
-
LinkedList()
-
-
append(Object)
- insert after the tail of the list
-
currentElement()
-
-
cursor()
-
-
elements()
-
-
hasMoreElements()
- a function to return true iff the cursor is not at the end of
the list.
-
insert(Object)
- insert before the iterator position
-
nextElement()
- a function to move the cursor to the next position
-
remove()
- remove the element under the cursor
-
reset()
-
a function to reset the cursor to null.
-
size()
-
head
private Link head
tail
private Link tail
pre
private Link pre
len
private int len
LinkedList
public LinkedList()
reset
public void reset()
- a function to reset the cursor to null.
hasMoreElements
public boolean hasMoreElements()
- a function to return true iff the cursor is not at the end of
the list.
nextElement
public Object nextElement()
- a function to move the cursor to the next position
- Returns:
- the current element (before advancing the position)
- Throws: NoSuchElementException
- if alread at the end of the list.
currentElement
public Object currentElement()
- Returns:
- the current element under the cursor
- Throws: NoSuchElementException
- if already at the end of the list.
insert
public void insert(Object n)
- insert before the iterator position
- Parameters:
- n - the object to insert
append
public void append(Object n)
- insert after the tail of the list
- Parameters:
- n - - the value to insert
remove
public Object remove()
- remove the element under the cursor
- Returns:
- the removed element
- Throws: NoSuchElementException
- if already at the end of the list
size
int size()
- Returns:
- the number of elements in the list.
elements
public Enumeration elements()
- Returns:
- an enumeration to iterate through all elements in the list
cursor
private Link cursor()
- Returns:
- the Link pointed to by the cursor.