dataStructures
Class SimulatedChain

java.lang.Object
  |
  +--dataStructures.SimulatedChain

public class SimulatedChain
extends java.lang.Object
implements LinearList


Field Summary
protected  int firstNode
           
static SimulatedSpace1 S
           
protected  int size
           
 
Constructor Summary
SimulatedChain()
           
SimulatedChain(int initialCapacity)
          create a list that is empty
 
Method Summary
 void add(int index, java.lang.Object obj)
          Insert an element with specified index.
 java.util.Iterator elements()
          create and return an iterator
 java.lang.Object get(int index)
           
 int indexOf(java.lang.Object elem)
           
 boolean isEmpty()
           
static void main(java.lang.String[] args)
          test program
 java.lang.Object remove(int index)
          Remove the element with specified index.
 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 int firstNode

size

protected int size

S

public static SimulatedSpace1 S
Constructor Detail

SimulatedChain

public SimulatedChain(int initialCapacity)
create a list that is empty

SimulatedChain

public SimulatedChain()
Method Detail

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface LinearList
Returns:
true iff list is empty

size

public int size()
Specified by:
size in interface LinearList
Returns:
current number of elements in list

get

public java.lang.Object get(int index)
Specified by:
get in interface LinearList
Returns:
element with specified index
Throws:
IndexOutOfBoundsException - when index is not between 0 and size - 1

indexOf

public int indexOf(java.lang.Object elem)
Specified by:
indexOf in interface LinearList
Returns:
index of first occurrence of elem, return -1 if elem not in list

remove

public java.lang.Object remove(int index)
Remove the element with specified index. All elements with higher index have their index reduced by 1.
Specified by:
remove in interface LinearList
Returns:
removed element
Throws:
IndexOutOfBoundsException - when index is not between 0 and size - 1

add

public void add(int index,
                java.lang.Object obj)
Insert an element with specified index. All elements with equal or higher index have their index increased by 1.
Specified by:
add in interface LinearList
Throws:
IndexOutOfBoundsException - when index is not between 0 and size

toString

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

elements

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

main

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