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>
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
ConstructorDescriptionContextIterable
(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
Modifier and TypeMethodDescriptionvoid
eventOccured
(ContextEvent<T> ev) Notify this event of a change to a context.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 Details
-
ContextIterable
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
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
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.
-