dataStructures
Class SortedChain

java.lang.Object
  |
  +--dataStructures.SortedChain
Direct Known Subclasses:
SortedChainWithDuplicates

public class SortedChain
extends java.lang.Object
implements Dictionary


Inner Class Summary
protected static class SortedChain.SortedChainNode
           
 
Field Summary
protected  SortedChain.SortedChainNode firstNode
           
protected  int size
           
 
Constructor Summary
SortedChain()
           
SortedChain(int initialCapacity)
          create an empty sorted chain
 
Method Summary
 java.lang.Object get(java.lang.Object theKey)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
          create and return an iterator
static void main(java.lang.String[] args)
          test program
 java.lang.Object put(java.lang.Object theKey, java.lang.Object theElement)
          insert an element with the specified key overwrite old element if there is already an element with the given key
 java.lang.Object remove(java.lang.Object theKey)
           
 int size()
           
 java.lang.String toString()
          convert to a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

firstNode

protected SortedChain.SortedChainNode firstNode

size

protected int size
Constructor Detail

SortedChain

public SortedChain(int initialCapacity)
create an empty sorted chain

SortedChain

public SortedChain()
Method Detail

isEmpty

public boolean isEmpty()
Returns:
true iff the chain is empty

size

public int size()
Returns:
current number of elements in list

get

public java.lang.Object get(java.lang.Object theKey)
Specified by:
get in interface Dictionary
Returns:
element with specified key

put

public java.lang.Object put(java.lang.Object theKey,
                            java.lang.Object theElement)
insert an element with the specified key overwrite old element if there is already an element with the given key
Specified by:
put in interface Dictionary
Returns:
old element (if any) with key theKey

remove

public java.lang.Object remove(java.lang.Object theKey)
Specified by:
remove in interface Dictionary
Returns:
matching element and remove it

toString

public java.lang.String toString()
convert to a string
Overrides:
toString in class java.lang.Object

iterator

public java.util.Iterator iterator()
create and return an iterator

main

public static void main(java.lang.String[] args)
test program