jds.collection
Class LinkedList

java.lang.Object
  |
  +--jds.collection.LinkedList
Direct Known Subclasses:
SelfOrgList

public class LinkedList
extends java.lang.Object
implements Bag, Deque

LinkedList - collection based on a sequence of linked values; for use with book Classic Data Structures in Java by Timothy A Budd, published by Addison-Wesley, 2001.

See Also:
Collection, Serialized Form

Constructor Summary
LinkedList()
          initialize newly created list
 
Method Summary
 void addElement(java.lang.Object newValue)
          add a new value to the collection
 void addFirst(java.lang.Object newValue)
          add a new value to front of the collection
 void addLast(java.lang.Object newValue)
          add a new value to end of the collection
 boolean containsElement(java.lang.Object test)
          see if collection contains value
 java.util.Enumeration elements()
          Yields enumerator for collection
 java.lang.Object findElement(java.lang.Object test)
          find element that will test equal to value
 java.lang.Object getFirst()
          access the first value in collection
 java.lang.Object getLast()
          access the last value in collection
 boolean isEmpty()
          Determines whether the collection is empty
 void removeElement(java.lang.Object newValue)
          remove a new value from the collection
 void removeFirst()
          remove first value in collection
 void removeLast()
          remove last value in collection
 int size()
          Determines number of elements in collection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
initialize newly created list
Method Detail

isEmpty

public boolean isEmpty()
Determines whether the collection is empty
Returns:
true if the collection is empty

size

public int size()
Determines number of elements in collection
Returns:
number of elements in collection as integer

elements

public java.util.Enumeration elements()
Yields enumerator for collection
Returns:
an Enumeration that will yield the elements of the collection
See Also:
Enumeration

addFirst

public void addFirst(java.lang.Object newValue)
add a new value to front of the collection
Specified by:
addFirst in interface Deque
Parameters:
value - element to be inserted into collection

addLast

public void addLast(java.lang.Object newValue)
add a new value to end of the collection
Parameters:
value - element to be inserted into collection

getFirst

public java.lang.Object getFirst()
access the first value in collection
Returns:
element at front of collection
Throws:
java.util.NoSuchElementException - no matching value

removeFirst

public void removeFirst()
remove first value in collection
Throws:
java.util.NoSuchElementException - no matching value

getLast

public java.lang.Object getLast()
access the last value in collection
Returns:
element at top of collection
Throws:
java.util.NoSuchElementException - no matching value

removeLast

public void removeLast()
remove last value in collection
Throws:
java.util.NoSuchElementException - no matching value

addElement

public void addElement(java.lang.Object newValue)
add a new value to the collection
Specified by:
addElement in interface Bag
Parameters:
newValue - element to be inserted into collection

containsElement

public boolean containsElement(java.lang.Object test)
see if collection contains value
Specified by:
containsElement in interface Bag
Parameters:
test - element to be tested
Returns:
true if collection contains value

findElement

public java.lang.Object findElement(java.lang.Object test)
find element that will test equal to value
Specified by:
findElement in interface Bag
Parameters:
value - element to be tested
Returns:
first value that is equals to argument
Throws:
java.util.NoSuchElementException - no matching value

removeElement

public void removeElement(java.lang.Object newValue)
remove a new value from the collection
Specified by:
removeElement in interface Bag
Parameters:
value - element to be removed from collection
Throws:
java.util.NoSuchElementException - no matching value