Class N14_Extra_DataStructureIteration.TaskAbstract

java.lang.Object
  extended by N14_Extra_DataStructureIteration.TaskAbstract
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
N14_Extra_DataStructureIteration.ArrayIteration, N14_Extra_DataStructureIteration.CollectionIteration, N14_Extra_DataStructureIteration.MapIteration
Enclosing class:
N14_Extra_DataStructureIteration

protected abstract static class N14_Extra_DataStructureIteration.TaskAbstract
extends Object
implements Runnable

Abstract base class for Tasks which measure the iteration time of Iterable data structures: arrays, Collections, Maps.

Subclasses must obey all the rules below.

Rule #1: a dedicated subclass must written for each type of data structure.

Rule #2: each subclass must implement its run method something like:


                public void run() {
                        dce = 0;        // do this so that each call of this method should
                        for (Integer i : [some Iterable]) {
                                dce ^= i;
                        }
                }
 

Rule #3: all subclass data structures must be isomorphic to the result of makeIntegers, namely, their (index/key, value) pairs must be identical to makeIntegers. This requirement is atuomatically satisfied by {link ArrayIteration} and its subclasses. Those subclasses which are Collections should clear themselves and then add all the elements of makeIntegers. Those subclasses which are Maps should clear themselves and then in a loop over the elements of makeIntegers do map.put( integer, integer );.

The reason for these rules is to ensure that each data structure is as similar as possible to make comparison easier.

The other functionality defined in this base class is DCE prevention, given that subclasses will be Runnable task classes.


Field Summary
protected  int dce
          Used to prevent DCE.
protected  int size
          Size of the data structure.
 
Constructor Summary
protected N14_Extra_DataStructureIteration.TaskAbstract(int size)
           
 
Method Summary
protected  Integer[] makeIntegers()
          Returns an Integer[] that always contains the numbers [0, size - 1] in order.
 String toString()
          Returns the String representation of dce to prevent DCE.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

size

protected final int size
Size of the data structure.


dce

protected int dce
Used to prevent DCE.

Constructor Detail

N14_Extra_DataStructureIteration.TaskAbstract

protected N14_Extra_DataStructureIteration.TaskAbstract(int size)
                                                 throws IllegalArgumentException
Throws:
IllegalArgumentException
Method Detail

makeIntegers

protected Integer[] makeIntegers()
Returns an Integer[] that always contains the numbers [0, size - 1] in order.


toString

public String toString()
Returns the String representation of dce to prevent DCE.

Overrides:
toString in class Object