Class ContextIterable<T>

java.lang.Object
repast.simphony.util.collections.RandomIterable<T>
repast.simphony.context.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.
Version:
$Revision$ $Date$
Author:
Nick Collier
  • Constructor Details

    • 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.
      Parameters:
      iter -
      count -
      context - the context associated with this iterable. This will listen on the context and respond appropriately to remove events
  • Method Details

    • 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>
      Overrides:
      next in class RandomIterable<T>
      Returns:
      the next element in the iteration.
      Throws:
      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>
      Parameters:
      ev - The event of which to notify the listener.