Provides Facade objects for working with the algorithm functors, and a variety of utility iterators for various purposes.
See: Description
Class Summary | |
---|---|
Algorithms | Facade for the Algorithms adapted from STL, defined to work primarily with collections. |
ComparableComparator<T> | Comparator used for objects that extend Comparable. |
EmptyIterator<T> | Iterator over an empty set of elements. |
EnumerationIterator<T> | Adapts an Enumeration to the Iterator interface. |
FilterIterator<T> | Iterator that only returns elements that meet the given selection criteria. |
FindIterator<T> | Iterator that provides the ability to skip to the first/next element that meets a particular criteria. |
GenericComparator<T,R> | Comparator that applies a functor to each argument, then compares the results. |
IteratorComparator<T> | Comparator used to compare iterations lexically. |
Iterators | Facade for the Algorithms adapted from STL, defined to work primarily with iterators. |
LookAheadIterator<T> | Iterator that allows the program to look at and operate on the next few elements without consuming them. |
SingletonIterator<T> | Iterates over a single item. |
StringTokenizerIterator | Adapts a StringTokenizer to the Iterator interface. |
TransformIterator<T,R> | Iterator that returns the results of applying the given functor to the elements of the given iterator. |
UniqueIterator<T> | Iterator that will not return the same element twice in succession. |
The functionality that is adapted from STL is provided by a set of functors in the net.sf.jga.fn.algorithm package operate on iterators. To ease the transition to this approach, there are two facade objects whose methods correspond to the algorithms provided by STL.
The first, Algorithms, operates on collections, and is appropriate for getting easy answers to common questions over collections. The second, Iterators, is closer conceptually to the implementation, and is more appropriate if the same function is to be called several times for a given collection. Most of the methods in these two facades are a single logical statement (although sometimes the singe statement is broken up for formatting reasons) that constructs and invokes the appropriate algorithm functor.
The summary of the functions adapted from STL is as follows:
STL Function name | Facade method name | functor |
---|---|---|
find() | find() | Find |
find_if() | find() | Find |
adjacent_find() | findAdjacent() | FindAdjacent |
find_first_of() | findElement() | FindElement |
search() | match() | FindSequence |
mismatch() | mismatch() | FindMismatch |
find_end() | n/a (1) | n/a 1 |
search_n() | findRepeated() | FindRepeated |
count() | count() | Count |
count_if() | count() | Count |
for_each() | forEach() | ForEach (2) |
equal() | equal() | varies based on form (3) |
lexicographical_compare() | lessThan() | varies based on form (3) |
min() | minimum() | Find,MinValue (4) |
min_element() | minimumValue() | MaxValue [collection] Accumulate [iteration] |
max() | maximum() | Find,MaxValue (4) |
max_element() | maximumValue() | MaxValue [collection] Accumulate [iteration] |
accumulate() | accumulate() | Accumulate (5) |
transform (unary form) | transformCopy | TransformUnary |
transform (binary form) | transformCopy | TransformUnary |
replace() | replaceAll | n/a(6) |
replace_if() | replaceAll | TransformUnary (w/ Conditional.replaceAll) |
replace_copy() | replaceAllCopy | TransformUnary(7) |
replace_copy_if() | replaceAllCopy | TransformUnary(7) |
remove() | removeAll | n/a(6) |
remove_if() | removeAll | FilterIterator |
remove_copy() | removeAllCopy | FilterIterator(7) |
remove_copy_if() | removeAllCopy | FilterIterator(7) |
unique() | unique | n/a(6) |
unique_copy() | uniqueCopy | UniqueIterator(7) |
FindLast(FindSequance())
accumulate(collection, new Integer(0), new Add<Integer>)())