|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jutil.java.collections.IntegerAccumulator
An integer accumulator for collections.
IntegerAccumulators process each element of a collection, and update an accumulator while doing so. The original collection remains unchanged.
Field Summary | |
static java.lang.String |
CVS_REVISION
|
Constructor Summary | |
IntegerAccumulator()
|
Method Summary | |
abstract int |
accumulate(java.lang.Object element,
int acc)
// The given element may not be null pre element != null; |
int |
in(java.util.Collection collection)
public behavior pre (\forall Object o, collection.contains(o); isValidElement(o)); post (* the result of the accumulation is returned *); post collection == null => \result == initialAccumulator(); signals (ConcurrentModificationException) (* The collection was modified while filtering *); |
abstract int |
initialAccumulator()
Subclasses should implement this method to return the initialized accumulator. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CVS_REVISION
Constructor Detail |
public IntegerAccumulator()
Method Detail |
public abstract int initialAccumulator()
Subclasses should implement this method to return the initialized accumulator.
This method is called at the start of the accumulation. The result will be used
in the application of public int accumulate(Object element, int acc)
for the first element.
public abstract int accumulate(java.lang.Object element, int acc)
This method is called for each element in the collection we are accumulating.
Subclasses should implement this method to process
The result is the accumulator that will be used for the next element of the collection to process.
.element
- The object the method will process and change the accumulator with.acc
- The accumulator for the accumulation.
For the first element to be processed, the result of initialAccumulator
is used. For the other elements, the result of this method applied on
the previous element is used.public int in(java.util.Collection collection)
Perform the accumulation defined in
public int accumulate(Object element, int acc)
for each
element of public int initialAccumulator()
is used as accumulator.
For the other elements, the result of the application of
public int accumulate(Object element, int acc)
on the
previous element is used as accumulator.
The contents of
The result of this method is the object returned by the application of
public int accumulate(Object element, int acc)
on the
last element of the collection to be processed.
collection
- The collection to perform this accumulation on. It will not be changed.
This can be null, in which the initial accumulator is returned.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |