|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectN14_Extra_DataStructureIteration.TaskAbstract
protected abstract static class N14_Extra_DataStructureIteration.TaskAbstract
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 |
---|
protected final int size
protected int dce
Constructor Detail |
---|
protected N14_Extra_DataStructureIteration.TaskAbstract(int size) throws IllegalArgumentException
IllegalArgumentException
Method Detail |
---|
protected Integer[] makeIntegers()
public String toString()
dce
to prevent DCE.
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |