net.sf.jga.util
Class Iterators

java.lang.Object
  extended by net.sf.jga.util.Iterators

Deprecated. all of the remaining functionality has been moved into

public class Iterators
extends java.lang.Object

Facade for the Algorithms adapted from STL, defined to work primarily with iterators. These algorithms are adapted from STL, with modifications to be consistent with typical java practice. For example, typical STL algorithms are defined with pairs of iterators defining a half-open range over some implied collection. It works in C++ because the STL iterators can be compared for equality. Java iterators are not guaranteed to be comparable to each other by contract, so the same signatures wouldn't work.

Typically, where an STL algorithm would take a pair of iterators, this facade will take a single iterator and where an STL algorithm would return an iterator, we'll return an iterator. In this facade, the iterator returned will frequently be specialized in some way: either a ListIterator or one of the iterators defined in jga.

It is best to assume that all of the methods in this class may (but are not guaranteed to) advance the iterator argument. Also, once an iterator has been passed to one of the methods of this class, it should not be used again. On the other hand, unless otherwise noted, it is safe to pass the iterator returned by one of the methods in this class back to the method that returned it, or to any of the other methods.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall

Constructor Summary
Iterators()
          Deprecated.  
 
Method Summary
static
<T extends java.lang.Comparable<? super T>>
boolean
equal(java.util.Iterator<? extends T> iterator1, java.util.Iterator<? extends T> iterator2)
          Deprecated. use Compare.equal(Iterator,Iterator) instead
static
<T> boolean
equal(java.util.Iterator<? extends T> iter1, java.util.Iterator<? extends T> iter2, BinaryFunctor<T,T,java.lang.Boolean> eq)
          Deprecated. use Compare.equal(Iterator,Iterator,BinaryFunctor) instead
static
<T> boolean
equal(java.util.Iterator<? extends T> iterator1, java.util.Iterator<? extends T> iterator2, java.util.Comparator<T> comp)
          Deprecated. use Compare.equal(Iterator,Iterator,Comparator) instead
static
<T,R> UnaryFunctor<T,R>
forEach(java.util.Iterator<? extends T> it, UnaryFunctor<T,R> fn)
          Deprecated. moved to Summarize.forEach(it,fn)
static
<T extends java.lang.Comparable<? super T>>
boolean
lessThan(java.util.Iterator<? extends T> iter1, java.util.Iterator<? extends T> iter2)
          Deprecated. use Compare.lessThan(Iterator,Iterator) instead
static
<T> boolean
lessThan(java.util.Iterator<? extends T> i1, java.util.Iterator<? extends T> i2, BinaryFunctor<T,T,java.lang.Boolean> lt)
          Deprecated. use Compare.lessThan(Iterator,Iterator,BinaryFunctor) instead
static
<T> boolean
lessThan(java.util.Iterator<? extends T> iter1, java.util.Iterator<? extends T> iter2, java.util.Comparator<T> comp)
          Deprecated. use Compare.lessThan(Iterator,Iterator,Comparator)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Iterators

public Iterators()
Deprecated. 
Method Detail

forEach

public static <T,R> UnaryFunctor<T,R> forEach(java.util.Iterator<? extends T> it,
                                              UnaryFunctor<T,R> fn)
Deprecated. moved to Summarize.forEach(it,fn)

Applies the given UnaryFunctor to every element in the iteration, and returns the Functor. This is useful when the Functor gathers information on each successive call.

Returns:
the functor, after it has been called once for every element

equal

public static <T extends java.lang.Comparable<? super T>> boolean equal(java.util.Iterator<? extends T> iterator1,
                                                                        java.util.Iterator<? extends T> iterator2)
Deprecated. use Compare.equal(Iterator,Iterator) instead

Returns true if the two iterations are equal, using the Comparable interface to compare elements in the iterations.

Returns:
true if the two iterations are equal

equal

public static <T> boolean equal(java.util.Iterator<? extends T> iterator1,
                                java.util.Iterator<? extends T> iterator2,
                                java.util.Comparator<T> comp)
Deprecated. use Compare.equal(Iterator,Iterator,Comparator) instead

Returns true if the two iterations are equal, using the given Comparator to compare elements in the iterations.

Returns:
true if the two iterations are equal

equal

public static <T> boolean equal(java.util.Iterator<? extends T> iter1,
                                java.util.Iterator<? extends T> iter2,
                                BinaryFunctor<T,T,java.lang.Boolean> eq)
Deprecated. use Compare.equal(Iterator,Iterator,BinaryFunctor) instead

Returns true if the two iterations are equal, using the given BinaryFunctor to compare elements in the iterations.

Returns:
true if the two iterations are equal

lessThan

public static <T extends java.lang.Comparable<? super T>> boolean lessThan(java.util.Iterator<? extends T> iter1,
                                                                           java.util.Iterator<? extends T> iter2)
Deprecated. use Compare.lessThan(Iterator,Iterator) instead

Returns true if the first iterator is lexically less than the second, using the default comparison operation to compare the elements in each iterator.

Returns:
true if the first iteration is less than the second

lessThan

public static <T> boolean lessThan(java.util.Iterator<? extends T> iter1,
                                   java.util.Iterator<? extends T> iter2,
                                   java.util.Comparator<T> comp)
Deprecated. use Compare.lessThan(Iterator,Iterator,Comparator)

Returns true if the first iterator is lexically less than the second, using the given comparator to compare the elements in each iterator.

Returns:
true if the first iteration is less than the second

lessThan

public static <T> boolean lessThan(java.util.Iterator<? extends T> i1,
                                   java.util.Iterator<? extends T> i2,
                                   BinaryFunctor<T,T,java.lang.Boolean> lt)
Deprecated. use Compare.lessThan(Iterator,Iterator,BinaryFunctor) instead

Returns true if the first iterator is lexically less than the second, using the given operator to compare the elements in each iterator. The first is less than the second if it is not longer than the second and if the first corresponding element that is not equal is less.

Returns:
true if the first iteration is less than the second


Copyright © 2002-2006 David A. Hall. All Rights Reserved.