rcf.core.util.groups
Class ImmutablePair.Iterable<A,B>

java.lang.Object
  extended by rcf.core.util.groups.ImmutableSingleton<A>
      extended by rcf.core.util.groups.ImmutablePair<rcf.core.util.collection.iterator.ImmutableFixedUniIterable<A>,rcf.core.util.collection.iterator.ImmutableFixedUniIterable<B>>
          extended by rcf.core.util.groups.ImmutablePair.Iterable<A,B>
Type Parameters:
A - The type of the first entry in each pair.
B - The type of the second entry in each pair.
All Implemented Interfaces:
rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Pair<A,B>>, ImmutablePairInterface<rcf.core.util.collection.iterator.ImmutableFixedUniIterable<A>,rcf.core.util.collection.iterator.ImmutableFixedUniIterable<B>>, ImmutableSingletonInterface<rcf.core.util.collection.iterator.ImmutableFixedUniIterable<A>>, ImmutableIterable<Pair<A,B>>
Enclosing class:
ImmutablePair<A,B>

public static class ImmutablePair.Iterable<A,B>
extends ImmutablePair<rcf.core.util.collection.iterator.ImmutableFixedUniIterable<A>,rcf.core.util.collection.iterator.ImmutableFixedUniIterable<B>>
implements rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Pair<A,B>>

TODO: Javadoc Binds a pair of immutable iterable objects, allowing them to be iterated in tandem.

Version:
$Revision: 1.29 $
Author:
Greg Gibeling

Nested Class Summary
 
Nested classes/interfaces inherited from class rcf.core.util.groups.ImmutablePair
ImmutablePair.Accessor<A,B>, ImmutablePair.Iterable<A,B>, ImmutablePair.Iterator<A,B>
 
Field Summary
 
Fields inherited from class rcf.core.util.groups.ImmutablePair
b
 
Fields inherited from class rcf.core.util.groups.ImmutableSingleton
a
 
Constructor Summary
ImmutablePair.Iterable(rcf.core.util.collection.iterator.ImmutableFixedUniIterable<A> _a, rcf.core.util.collection.iterator.ImmutableFixedUniIterable<B> _b)
          TODO: Javadoc Create an immutable iterable pair from two immutable iterable objects.
 
Method Summary
 boolean isCompatible(ImmutablePosition<Pair<A,B>> p)
          TODO: Javadoc Determine if the specified position is compatible to, i.e.
 boolean isEmpty()
          TODO: Javadoc Return true if this iterable contains no elements.
 boolean isNative(ImmutablePosition<Pair<A,B>> p)
          TODO: Javadoc Determine if the specified position is native to, i.e.
 ImmutablePair.Iterator<A,B> makeNative(ImmutablePosition<Pair<A,B>> p)
          TODO: Javadoc Convert the specified position into an iterator native to this iterable.
 ImmutablePair.Iterator<A,B> post()
           
 ImmutablePair.Iterator<A,B> pre()
           
 ImmutablePair.Iterator<A,B> project(rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>> p)
           
 int size()
          TODO: Javadoc Return the number of elements which this iterable contains.
 
Methods inherited from class rcf.core.util.groups.ImmutablePair
equals, getA, getB, hashCode, toString
 
Methods inherited from class rcf.core.util.groups.ImmutableSingleton
get
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rcf.core.util.groups.ImmutableSingletonInterface
get
 

Constructor Detail

ImmutablePair.Iterable

public ImmutablePair.Iterable(rcf.core.util.collection.iterator.ImmutableFixedUniIterable<A> _a,
                              rcf.core.util.collection.iterator.ImmutableFixedUniIterable<B> _b)
TODO: Javadoc Create an immutable iterable pair from two immutable iterable objects.

Parameters:
_a - The A type iterable object.
_b - The B type iterable object.
Method Detail

isCompatible

public boolean isCompatible(ImmutablePosition<Pair<A,B>> p)
Description copied from interface: ImmutableIterable
TODO: Javadoc Determine if the specified position is compatible to, i.e. indicates a position in, this iterable object (should return true for pre- and post-sentinel positions). This method should never throw exceptions as it is a test to avoid them.

Note that this method will return true even for positions which did not original come from this iterable, for example in the case of an ImmutableFixedUniIterator over a ImmutableCollection.subCollection(rcf.core.util.collection.position.ImmutableFixedUniPosition, rcf.core.util.filter.Filter). To test if the specified position is native to this iterable, rather than just compatible with it, use the ImmutableIterable.isNative(ImmutablePosition) method.

Specified by:
isCompatible in interface ImmutableIterable<Pair<A,B>>
Parameters:
p - The position to determine if this iterable is compatible with.
Returns:
true indicates that the specified position is compatible with this iterable, and its iterators and methods.

isEmpty

public boolean isEmpty()
Description copied from interface: ImmutableIterable
TODO: Javadoc Return true if this iterable contains no elements.

Specified by:
isEmpty in interface ImmutableIterable<Pair<A,B>>
Returns:
true if this iterable contains no elements.

isNative

public boolean isNative(ImmutablePosition<Pair<A,B>> p)
Description copied from interface: ImmutableIterable
TODO: Javadoc Determine if the specified position is native to, i.e. indicates a position originally from this iterable object (should return true for pre- and post-sentinel positions). This method should never throw exceptions as it is a test to avoid them.

Note that this method will return false for positions which did not original come from this iterable, for example in the case of an ImmutableFixedUniIterator over a ImmutableCollection.subCollection(rcf.core.util.collection.position.ImmutableFixedUniPosition, rcf.core.util.filter.Filter). The positions may still be used as arguments to most methods both on this iterable and the ImmutableIterators it creates, but they are not native to it, and may behave differently under iteration. To test if the specified position is compatible with this iterable and its iterators, rather than native to it, use the ImmutableIterable.isCompatible(ImmutablePosition) method.

Specified by:
isNative in interface ImmutableIterable<Pair<A,B>>
Parameters:
p - The position to determine if this iterable is native to.
Returns:
true indicates that the specified position is native to this iterable.

makeNative

public ImmutablePair.Iterator<A,B> makeNative(ImmutablePosition<Pair<A,B>> p)
Description copied from interface: ImmutableIterable
TODO: Javadoc Convert the specified position into an iterator native to this iterable. Note that if the specified position is already native to this iterable, it will be returned, not a copy of it. If it is not native, a ImmutableIterator.copy() will be returned.

Specified by:
makeNative in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Pair<A,B>>
Specified by:
makeNative in interface ImmutableIterable<Pair<A,B>>
Parameters:
p - The position to return a native version of.
Returns:
The position p if it is native to this iterable, or, if isCompatible(p) a position q such that q.equals(p) && isNative(q) && (q != p). Otherwise, if !isCompatible(p), this method will return null.

post

public ImmutablePair.Iterator<A,B> post()
Specified by:
post in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Pair<A,B>>

pre

public ImmutablePair.Iterator<A,B> pre()
Specified by:
pre in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Pair<A,B>>

project

public ImmutablePair.Iterator<A,B> project(rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>> p)
Specified by:
project in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Pair<A,B>>

size

public int size()
Description copied from interface: ImmutableIterable
TODO: Javadoc Return the number of elements which this iterable contains. If there are more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE. This method should always run in O(1), trivial time. Complex iterables must keep an up-to-date size count to ensure this method runs extremely quickly.

Specified by:
size in interface ImmutableIterable<Pair<A,B>>
Returns:
The number of elements in this iterable.