Class ContextIterable<T>

  • All Implemented Interfaces:
    Iterable<T>, Iterator<T>, ContextListener<T>

    public class ContextIterable<T>
    extends RandomIterable<T>
    implements ContextListener<T>
    An iterable that iterates over a collection of objects at random. The "length" of the iterable may be less than the number of objects in the collection.
    $Revision$ $Date$
    Nick Collier
    • Constructor Detail

      • ContextIterable

        public ContextIterable​(IndexedIterable<T> iter,
                               long count,
                               Context<T> context)
        Creates a RandomIterable that will iterate over count number of objects in the specified IndexedIterable.
        iter -
        count -
        context - the context associated with this iterable. This will listen on the context and respond appropriately to remove events
    • Method Detail

      • next

        public T next()
        Returns the next element in the iteration. Calling this method repeatedly until the RandomIterable.hasNext() method returns false will return each element in the underlying collection exactly once.
        Specified by:
        next in interface Iterator<T>
        next in class RandomIterable<T>
        the next element in the iteration.
        NoSuchElementException - iteration has no more elements.
      • eventOccured

        public void eventOccured​(ContextEvent<T> ev)
        Notify this event of a change to a context.
        Specified by:
        eventOccured in interface ContextListener<T>
        ev - The event of which to notify the listener.