Class LinkedList

java.lang.Object
  |
  +--LinkedList

public class LinkedList
extends java.lang.Object

Class LinkedList A minimal LinkedList class composed of Node objects for 15-111/200 Mastery Exam/Fall 2002 You need to add a method to this class as described in the instructions. You may add additional helper (private) methods if you choose, but you may not add additional public methods, nor may you change those methods that we have defined. Name: Section: Date: andrew e-mail:


Constructor Summary
LinkedList()
          Default constructor: sets head to null, count to 0
 
Method Summary
 void addFirst(java.lang.Comparable item)
          Inserts a Comparable item at the beginning of the list
 boolean isEmpty()
          Tests list to see if it is empty
 void removeItems(LinkedList otherList)
          Precondition: this list is sorted and the otherList list is sorted in the order proscribed by the data item's compareTo() method Postcondition: this list has all the items from the original list that were not contained in the parameter otherList otherList is unchanged
 int size()
          Returns the number of nodes in the list
 java.lang.String toString()
          Returns a string representation of the list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Default constructor: sets head to null, count to 0
Method Detail

removeItems

public void removeItems(LinkedList otherList)
Precondition: this list is sorted and the otherList list is sorted in the order proscribed by the data item's compareTo() method Postcondition: this list has all the items from the original list that were not contained in the parameter otherList otherList is unchanged
Parameters:
otherList - the sorted list with the items to be removed from this list

size

public int size()
Returns the number of nodes in the list
Returns:
int the value of count

isEmpty

public boolean isEmpty()
Tests list to see if it is empty
Returns:
boolean: true if the list is empty

addFirst

public void addFirst(java.lang.Comparable item)
Inserts a Comparable item at the beginning of the list
Parameters:
Comparable - item to be added into the LinkedList

toString

public java.lang.String toString()
Returns a string representation of the list
Overrides:
toString in class java.lang.Object
Returns:
String