Class LinkedList

java.lang.Object
   |
   +----LinkedList

public class LinkedList
extends Object

NetRand Project

Software Engineering - CS536

University of Wisconsin - Milwaukee

Authors:


File: LinkedList.java

LinkedList Class: implements the a linked-list data structure.


Variable Index

 o head
 o len
 o pre
 o tail

Constructor Index

 o LinkedList()

Method Index

 o append(Object)
insert after the tail of the list
 o currentElement()
 o cursor()
 o elements()
 o hasMoreElements()
a function to return true iff the cursor is not at the end of the list.
 o insert(Object)
insert before the iterator position
 o nextElement()
a function to move the cursor to the next position
 o remove()
remove the element under the cursor
 o reset()
a function to reset the cursor to null.
 o size()

Variables

 o head
 private Link head
 o tail
 private Link tail
 o pre
 private Link pre
 o len
 private int len

Constructors

 o LinkedList
 public LinkedList()

Methods

 o reset
 public void reset()
a function to reset the cursor to null.

 o hasMoreElements
 public boolean hasMoreElements()
a function to return true iff the cursor is not at the end of the list.

 o 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.
 o currentElement
 public Object currentElement()
Returns:
the current element under the cursor
Throws: NoSuchElementException
if already at the end of the list.
 o insert
 public void insert(Object n)
insert before the iterator position

Parameters:
n - the object to insert
 o append
 public void append(Object n)
insert after the tail of the list

Parameters:
n - - the value to insert
 o remove
 public Object remove()
remove the element under the cursor

Returns:
the removed element
Throws: NoSuchElementException
if already at the end of the list
 o size
 int size()
Returns:
the number of elements in the list.
 o elements
 public Enumeration elements()
Returns:
an enumeration to iterate through all elements in the list
 o cursor
 private Link cursor()
Returns:
the Link pointed to by the cursor.