xxl.cursors
Class Cursors

java.lang.Object
  |
  +--xxl.cursors.Cursors

public abstract class Cursors
extends java.lang.Object

This class contains various methods for manipulating Iterators.


Constructor Summary
Cursors()
           
 
Method Summary
static boolean all(java.util.Iterator[] iterators, Function function)
          Returns true iff function returns Boolean.TRUE for each vector of elements of iterators while all iterators are not empty.
static boolean all(java.util.Iterator iterator, Function function)
          Returns true iff function returns Boolean.TRUE for each element of iterator.
static boolean all(java.util.Iterator iterator1, java.util.Iterator iterator2, Function function)
          Returns true iff function returns Boolean.TRUE for each pair of elements of iterator1 and iterator2 while both iterators are not empty.
static boolean any(java.util.Iterator[] iterators, Function function)
          Returns true iff function returns Boolean.TRUE for any vector of elements of iterators while all iterators are not empty.
static boolean any(java.util.Iterator iterator, Function function)
          Returns true iff function returns Boolean.TRUE for any element of iterator.
static boolean any(java.util.Iterator iterator1, java.util.Iterator iterator2, Function function)
          Returns true iff function returns Boolean.TRUE for any pair of elements of iterator1 and iterator2 while both iterators are not empty.
static int count(java.util.Iterator iterator)
          Counts the elements of a specified Iterator.
static java.lang.Object first(java.util.Iterator iterator)
          Returns the first element of an Iterator.
static void forEach(java.util.Iterator[] iterators, Function function)
          Invokes function for each vector of elements of iterators while all iterators are not empty.
static void forEach(java.util.Iterator iterator, Function function)
          Invokes function for each element of the iterator.
static void forEach(java.util.Iterator iterator1, java.util.Iterator iterator2, Function function)
          Invokes function for each pair of elements of iterator1 and iterator2 while both iterators are not empty.
static java.lang.Object last(java.util.Iterator iterator)
          Returns the last element of an Iterator.
static java.util.LinkedList minima(java.util.Iterator iterator)
          Returns the list of objects equal to the minimal value in the same order provided by the iterator as its value using a ComparableComparator.
static java.util.LinkedList minima(java.util.Iterator iterator, java.util.Comparator comparator)
          Returns the list of objects equal to the minimal value in the same order provided by the iterator as its value.
static java.util.LinkedList minima(java.util.Iterator iterator, Function getFeature)
          Returns the list of objects having the minimal value in the same order provided by the iterator using a ComparableComparator.
static java.util.LinkedList minima(java.util.Iterator iterator, Function getFeature, java.util.Comparator comparator)
          Returns the list of objects having the minimal value in the same order provided by the iterator.
static java.util.Map.Entry minimize(java.util.Iterator iterator)
          Returns a Map.Entry-object with the minimal value as its key and the list of objects equal to the minimal value in the same order provided by the iterator as its value using a ComparableComparator.
static java.util.Map.Entry minimize(java.util.Iterator iterator, java.util.Comparator comparator)
          Returns a Map.Entry-object with the minimal value as its key and the list of objects equal to the minimal value in the same order provided by the iterator as its value.
static java.util.Map.Entry minimize(java.util.Iterator iterator, Function getFeature)
          Returns a Map.Entry-object with the minimal value as its key and the list of objects having this minimal value in the same order provided by the iterator as its value using a ComparableComparator.
static java.util.Map.Entry minimize(java.util.Iterator iterator, Function getFeature, java.util.Comparator comparator)
          Returns a Map.Entry-object with the minimal value as its key and the list of objects having this minimal value in the same order provided by the iterator as its value.
static java.lang.Object nth(java.util.Iterator iterator, int n)
          Returns the n-th element of an Iterator.
static void removeAll(java.util.Iterator iterator)
          Removes all elements of an Iterator.
static java.lang.Object[] toArray(java.util.Iterator iterator)
          Converts an Iterator to an Array whose length is equal to the number of the Iterator-elements.
static java.lang.Object[] toArray(java.util.Iterator iterator, java.util.Iterator indices)
          Converts an Iterator to an Array whose length is determined by the largest index.
static java.lang.Object[] toArray(java.util.Iterator iterator, java.lang.Object[] array)
          Converts an Iterator to an Array.
static java.lang.Object[] toArray(java.util.Iterator iterator, java.lang.Object[] array, java.util.Iterator indices)
          Converts an Iterator to an Array.
static java.util.Collection toCollection(java.util.Iterator iterator, java.util.Collection collection)
          Adds the elements of an Iterator to a given Collection.
static java.util.List toList(java.util.Iterator iterator)
          Converts an Iterator to a List.
static java.util.List toList(java.util.Iterator iterator, java.util.List list)
          Converts an Iterator to a List.
static java.util.Map toMap(java.util.Iterator iterator, Function getKey)
          Converts an Iterator to a HashMap.
static java.util.Map toMap(java.util.Iterator iterator, Function getKey, Function newCollection)
          Converts an Iterator to a HashMap.
static java.util.Map toMap(java.util.Iterator iterator, Function getKey, java.util.Map map)
          Converts an Iterator to a Map.
static java.util.Map toMap(java.util.Iterator iterator, Function getKey, java.util.Map map, Function newCollection)
          Converts an Iterator to a Map.
static void updateAll(Cursor cursor, Function function)
          Updates all elements of a Cursor with the result of a given Function.
static void updateAll(Cursor cursor, java.util.Iterator objects)
          Updates all elements of a Cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cursors

public Cursors()
Method Detail

forEach

public static void forEach(java.util.Iterator iterator,
                           Function function)
Invokes function for each element of the iterator.

forEach

public static void forEach(java.util.Iterator iterator1,
                           java.util.Iterator iterator2,
                           Function function)
Invokes function for each pair of elements of iterator1 and iterator2 while both iterators are not empty.

forEach

public static void forEach(java.util.Iterator[] iterators,
                           Function function)
Invokes function for each vector of elements of iterators while all iterators are not empty.

all

public static boolean all(java.util.Iterator iterator,
                          Function function)
Returns true iff function returns Boolean.TRUE for each element of iterator.

all

public static boolean all(java.util.Iterator iterator1,
                          java.util.Iterator iterator2,
                          Function function)
Returns true iff function returns Boolean.TRUE for each pair of elements of iterator1 and iterator2 while both iterators are not empty.

all

public static boolean all(java.util.Iterator[] iterators,
                          Function function)
Returns true iff function returns Boolean.TRUE for each vector of elements of iterators while all iterators are not empty.

any

public static boolean any(java.util.Iterator iterator,
                          Function function)
Returns true iff function returns Boolean.TRUE for any element of iterator.

any

public static boolean any(java.util.Iterator iterator1,
                          java.util.Iterator iterator2,
                          Function function)
Returns true iff function returns Boolean.TRUE for any pair of elements of iterator1 and iterator2 while both iterators are not empty.

any

public static boolean any(java.util.Iterator[] iterators,
                          Function function)
Returns true iff function returns Boolean.TRUE for any vector of elements of iterators while all iterators are not empty.

last

public static java.lang.Object last(java.util.Iterator iterator)
                             throws java.util.NoSuchElementException
Returns the last element of an Iterator.
Parameters:
iterator - input-Iterator
Returns:
the last element

nth

public static java.lang.Object nth(java.util.Iterator iterator,
                                   int n)
                            throws java.util.NoSuchElementException
Returns the n-th element of an Iterator.
Parameters:
iterator - input-Iterator
n - index of the element
Returns:
the n-th element

first

public static java.lang.Object first(java.util.Iterator iterator)
                              throws java.util.NoSuchElementException
Returns the first element of an Iterator.
Parameters:
iterator - input-Iterator
the - first element

count

public static int count(java.util.Iterator iterator)
Counts the elements of a specified Iterator.
Parameters:
iterator - input-Iterator
Returns:
the number of Elements

minimize

public static java.util.Map.Entry minimize(java.util.Iterator iterator,
                                           Function getFeature,
                                           java.util.Comparator comparator)
Returns a Map.Entry-object with the minimal value as its key and the list of objects having this minimal value in the same order provided by the iterator as its value.
Parameters:
iterator - the objects to be minimized
getFeature - the function obtaining the value for each object used to compare
comparator - the comparator that compares the values obtained by getFeature

minima

public static java.util.LinkedList minima(java.util.Iterator iterator,
                                          Function getFeature,
                                          java.util.Comparator comparator)
Returns the list of objects having the minimal value in the same order provided by the iterator.
Parameters:
iterator - the objects to be minimized
getFeature - the function obtaining the value for each object used to compare
comparator - the comparator that compares the values obtained by getFeature

minimize

public static java.util.Map.Entry minimize(java.util.Iterator iterator,
                                           Function getFeature)
Returns a Map.Entry-object with the minimal value as its key and the list of objects having this minimal value in the same order provided by the iterator as its value using a ComparableComparator.
Parameters:
iterator - the objects to be minimized
getFeature - the function obtaining the value for each object used to compare

minima

public static java.util.LinkedList minima(java.util.Iterator iterator,
                                          Function getFeature)
Returns the list of objects having the minimal value in the same order provided by the iterator using a ComparableComparator.
Parameters:
iterator - the objects to be minimized
getFeature - the function obtaining the value for each object used to compare

minimize

public static java.util.Map.Entry minimize(java.util.Iterator iterator,
                                           java.util.Comparator comparator)
Returns a Map.Entry-object with the minimal value as its key and the list of objects equal to the minimal value in the same order provided by the iterator as its value.
Parameters:
iterator - the objects to be minimized
comparator - the comparator that compares the objects

minima

public static java.util.LinkedList minima(java.util.Iterator iterator,
                                          java.util.Comparator comparator)
Returns the list of objects equal to the minimal value in the same order provided by the iterator as its value.
Parameters:
iterator - the objects to be minimized
comparator - the comparator that compares the objects

minimize

public static java.util.Map.Entry minimize(java.util.Iterator iterator)
Returns a Map.Entry-object with the minimal value as its key and the list of objects equal to the minimal value in the same order provided by the iterator as its value using a ComparableComparator.
Parameters:
iterator - the objects to be minimized

minima

public static java.util.LinkedList minima(java.util.Iterator iterator)
Returns the list of objects equal to the minimal value in the same order provided by the iterator as its value using a ComparableComparator.
Parameters:
iterator - the objects to be minimized

removeAll

public static void removeAll(java.util.Iterator iterator)
Removes all elements of an Iterator.
Parameters:
iterator - input-Iterator

updateAll

public static void updateAll(Cursor cursor,
                             java.util.Iterator objects)
Updates all elements of a Cursor.
Parameters:
cursor - input-Cursor
iterator - the Iterator with objects to be used for the update-operation

updateAll

public static void updateAll(Cursor cursor,
                             Function function)
Updates all elements of a Cursor with the result of a given Function.
Parameters:
cursor - input-Cursor
function - the Function used to compute the Object for the update-operation

toCollection

public static java.util.Collection toCollection(java.util.Iterator iterator,
                                                java.util.Collection collection)
Adds the elements of an Iterator to a given Collection.
Parameters:
iterator - input-Iterator
collection - the Collection to which the elements are to be added
Returns:
collection

toList

public static java.util.List toList(java.util.Iterator iterator,
                                    java.util.List list)
Converts an Iterator to a List.
Parameters:
iterator - input-Iterator
list - the list to which the elements are to be added
Returns:
List of Iterator-elements

toList

public static java.util.List toList(java.util.Iterator iterator)
Converts an Iterator to a List.
Parameters:
iterator - input-Iterator
Returns:
List of Iterator-elements

toArray

public static java.lang.Object[] toArray(java.util.Iterator iterator)
Converts an Iterator to an Array whose length is equal to the number of the Iterator-elements.
Parameters:
iterator - input-Iterator
Returns:
array of Iterator-elements

toArray

public static java.lang.Object[] toArray(java.util.Iterator iterator,
                                         java.util.Iterator indices)
Converts an Iterator to an Array whose length is determined by the largest index. Stops as soon as one iterator is exhausted.
Parameters:
iterator - input-Iterator
indices - each index determines where to store the corresponding Iterator-element.
Returns:
array of Iterator-elements whose length is equal to the number of the Iterator-elements

toArray

public static java.lang.Object[] toArray(java.util.Iterator iterator,
                                         java.lang.Object[] array,
                                         java.util.Iterator indices)
Converts an Iterator to an Array. Stops as soon as one iterator is exhausted. Throws an ArrayIndexOutOfBoundsException on demand.
Parameters:
iterator - input-Iterator
array - the array to be filled
indices - each index determines where to store the corresponding Iterator-element.
Returns:
the input-Array

toArray

public static java.lang.Object[] toArray(java.util.Iterator iterator,
                                         java.lang.Object[] array)
Converts an Iterator to an Array. Throws an ArrayIndexOutOfBoundsException if the number of Iterator-elements is larger than the length of the array.
Parameters:
iterator - input-Iterator
array - the array to be filled
Returns:
the input-Array

toMap

public static java.util.Map toMap(java.util.Iterator iterator,
                                  Function getKey,
                                  java.util.Map map,
                                  Function newCollection)
Converts an Iterator to a Map. Partitions the Iterator-elements according to the result of the function getKey. Each partition is the value-part of its corresponding map-entry and is implemented as a collection.
Parameters:
iterator - input-Iterator
getKey - function that determines for an Iterator-element its key
map - the map used to store the partitions
newCollection - creates a new collection to store the elements of a new partition
Returns:
the map implementing the partition of the Iterator-elements

toMap

public static java.util.Map toMap(java.util.Iterator iterator,
                                  Function getKey,
                                  java.util.Map map)
Converts an Iterator to a Map. Partitions the Iterator-elements according to the result of the function getKey. Each partition is the value-part of its corresponding map-entry and is implemented as a linked list.
Parameters:
iterator - input-Iterator
getKey - function that determines for an Iterator-element its key
map - the map used to store the partitions
Returns:
the map implementing the partition of the Iterator-elements

toMap

public static java.util.Map toMap(java.util.Iterator iterator,
                                  Function getKey,
                                  Function newCollection)
Converts an Iterator to a HashMap. Partitions the Iterator-elements according to the result of the function getKey. Each partition is the value-part of its corresponding map-entry and is implemented as a collection.
Parameters:
iterator - input-Iterator
getKey - function that determines for an Iterator-element its key
newCollection - creates a new collection to store the elements of a new partition
Returns:
the map implementing the partition of the Iterator-elements

toMap

public static java.util.Map toMap(java.util.Iterator iterator,
                                  Function getKey)
Converts an Iterator to a HashMap. Partitions the Iterator-elements according to the result of the function getKey. Each partition is the value-part of its corresponding map-entry and is implemented as a linked list.
Parameters:
iterator - input-Iterator
getKey - function that determines for an Iterator-element its key
Returns:
the map implementing the partition of the Iterator-elements