MetaDone
metadone.util.IteratorUtil Class Reference
Collaboration diagram for metadone.util.IteratorUtil:

List of all members.

Classes

class  ValueIterator< T >

Static Public Member Functions

static< T > Iterator< T > emptyIterator ()
static< T > Iterator< T > forValue (final T value)
static< T > Iterator< T > forValues (final T...values)
static< T > Iterator< T > forArray (final T[] arr)
static< T > ArrayList< T > readInto (Iterator< T > it)
static< T, CextendsCollection
< T > C 
readInto (Iterator<?extends T > it, C dest)
static boolean equal (Iterator<?> a, Iterator<?> b)
static< T > Iterator< T > concatenate (final Iterator<?extends T > it1, final Iterator<?extends T > it2)
static< T > Iterator< T > concatenate (final Iterator<?extends Iterator<?extends T >> its)
static< R, T > Iterator< R > map (final MapFct<?super T,?extends R > f, final Iterator< T > it)
static< R > Iterator< R > filter (final MapFct<?super R,?extends Boolean > predicate, final Iterator< R > it)

Private Member Functions

 IteratorUtil ()

Static Private Attributes

static final Iterator< Object > EMPTY_ITERATOR

Detailed Description

Functions for manipulating iterators.

Author:
kma (partially copied from one of my projects)

Constructor & Destructor Documentation

metadone.util.IteratorUtil.IteratorUtil ( ) [private]

Member Function Documentation

static <T> Iterator<T> metadone.util.IteratorUtil.concatenate ( final Iterator<?extends T >  it1,
final Iterator<?extends T >  it2 
) [static]

Concatenates two iterators.

Parameters:
<T>The type of the values
it1The first iterator
it2The second iterator
Returns:
An iterable returning values from it1 then from it2
Exceptions:
NullPointerExceptionwhen it1 or it2 is null

Referenced by metadone.client.grasyla2.GrasylaEngineFactory.getBuilders(), metadone.client.grasyla2.GrasylaEngineFactory.getBuilderSetClass(), metadone.client.grasyla2.SelectorBestEquation.getRelatedEquations(), and metadone.client.grasyla2.SelectorBestEquation.getRelatedEquationsAnyMetaclass().

static <T> Iterator<T> metadone.util.IteratorUtil.concatenate ( final Iterator<?extends Iterator<?extends T >>  its) [static]

Concatenates iterators returned by an iterator.

Parameters:
<T>The type of the elements
itsThe iterators
Returns:
The iterator over all the generated iterators
Exceptions:
NullPointerExceptionwhen its is null
static <T> Iterator<T> metadone.util.IteratorUtil.emptyIterator ( ) [static]
static boolean metadone.util.IteratorUtil.equal ( Iterator<?>  a,
Iterator<?>  b 
) [static]

Tests whether two iterators produce the same elements in the same order.

If one of the given iterables is null, the function returns true only if the other is also null.

Parameters:
aThe first iterable
bThe second iterable
Returns:
True when same values are produced

References metadone.util.Objects.equal().

Referenced by metadone.client.grasyla2.base.GrasylaComponent< C >.equals().

static <R> Iterator<R> metadone.util.IteratorUtil.filter ( final MapFct<?super R,?extends Boolean >  predicate,
final Iterator< R >  it 
) [static]

Filters values of an iterator.

If it = [v_i | i = 0..], the returned iterator generates values [v_i | i = 0.. and predicate(v_i)].

The Iterator#remove() method works only if it is called just after Iterator#next(). Otherwise, the result is unexpected.

Parameters:
<R>The type of the values
predicateThe filter function
itThe iterator
Returns:
A new iterator
Exceptions:
NullPointerExceptionwhen it or predicate is null
See also:
Objects.bool(Boolean)

Referenced by metadone.client.grasyla2.GrasylaEngine.getAttributes(), metadone.client.grasyla2.GrasylaEngine.getChildrenExpressions(), metadone.client.grasyla2.GrasylaEngine.getContainedAttributes(), metadone.client.grasyla2.GrasylaEngine.getContainedExpressions(), metadone.client.grasyla2.GrasylaEngine.getContainedVariables(), metadone.metabusiness.impl.ConcreteObject_impl.getFilteredConcreteRoles(), metadone.metabusiness.impl.ConcreteObject_impl.getLinkedObjects(), and metadone.client.grasyla2.SelectorBestEquation.getRelatedEquations().

static <T> Iterator<T> metadone.util.IteratorUtil.forArray ( final T[]  arr) [static]

Generates an iterator which returns values from the given array.

Parameters:
<T>The type of the values
arrThe input array
Returns:
An iterator

References metadone.util.IteratorUtil.emptyIterator().

Referenced by metadone.util.IteratorUtil.forValues().

static <T> Iterator<T> metadone.util.IteratorUtil.forValue ( final T  value) [static]

Generates an iterator which contains one value.

Parameters:
<T>The type of the value
valueThe value
Returns:
An iterator

Referenced by metadone.client.grasyla2.GrasylaEngineFactory.getBuilderSetClass().

static <T> Iterator<T> metadone.util.IteratorUtil.forValues ( final T...  values) [static]

Generates an iterator which contains the given values.

Parameters:
<T>The type of the values
valuesThe values
Returns:
An iterator

References metadone.util.IteratorUtil.forArray().

static <R,T> Iterator<R> metadone.util.IteratorUtil.map ( final MapFct<?super T,?extends R >  f,
final Iterator< T >  it 
) [static]

Maps a function to each element of an iterator.

If it = [v_i | i = 0..], the returned iterator generates values [f(v_i) | i = 0..].

Parameters:
<R>The returned type
<T>The iterator type
fThe function to apply
itThe iterator object
Returns:
A new iterable
Exceptions:
NullPointerExceptionwhen it or f is null

Referenced by metadone.client.grasyla2.GrasylaEngine.getAttributes(), metadone.client.grasyla2.GrasylaEngineFactory.getBuilders(), metadone.client.grasyla2.GrasylaEngine.getContainedAttributes(), metadone.metabusiness.impl.ConcreteObject_impl.getFilteredConcreteRolesCO(), metadone.client.grasyla2.value.Value.getValueAsCO(), and metadone.metabusiness.impl.ConcreteObject_impl.MapMetaToConcrete.map().

static <T,CextendsCollection<T> C metadone.util.IteratorUtil.readInto ( Iterator<?extends T >  it,
dest 
) [static]

Reads an iterator into a collection.

Parameters:
<T>The type of elements in the collection
<C>The collection type
itThe iterator
destThe destination collection
Returns:
dest
Exceptions:
NullPointerExceptionwhen it, dest is null or when the collection does not support adding null elements and a null element has been returned by the iterator

Member Data Documentation

final Iterator<Object> metadone.util.IteratorUtil.EMPTY_ITERATOR [static, private]
Initial value:
 new Iterator<Object>() {
        @Override
        public boolean hasNext() {
            return false;
        }

        @Override
        public Object next() {
            throw new NoSuchElementException();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String toString() {
            return "EmptyIterator";
        }
    }

Referenced by metadone.util.IteratorUtil.emptyIterator().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations