Package repast.simphony.context
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
-
-
Field Summary
-
Fields inherited from class repast.simphony.util.collections.RandomIterable
index, list, numReturned, numToReturn, returned
-
-
Constructor Summary
Constructors Constructor Description ContextIterable(IndexedIterable<T> iter, long count, Context<T> context)
Creates a RandomIterable that will iterate over count number of objects in the specified IndexedIterable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
eventOccured(ContextEvent<T> ev)
Notify this event of a change to a context.T
next()
Returns the next element in the iteration.-
Methods inherited from class repast.simphony.util.collections.RandomIterable
hasNext, iterator, remove, removeEvent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
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.- Parameters:
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 theRandomIterable.hasNext()
method returns false will return each element in the underlying collection exactly once.- Specified by:
next
in interfaceIterator<T>
- Overrides:
next
in classRandomIterable<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 interfaceContextListener<T>
- Parameters:
ev
- The event of which to notify the listener.
-
-