Package repast.simphony.context
Class SmallDefaultContext<T>
java.lang.Object
java.util.AbstractCollection<T>
repast.simphony.context.AbstractContext<T>
repast.simphony.context.SmallDefaultContext<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Context<T>,ContextListener,RepastElement
- Direct Known Subclasses:
DefaultContext
-
Field Summary
FieldsFields inherited from class repast.simphony.context.AbstractContext
subContextsFields inherited from interface repast.simphony.context.Context
SYN_CONTEXT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddInternal(T o) protected booleangetObjects(Class<?> clazz) Gets a IndexedIterable over all the objects in this context (and thus in the sub contexts) that are of the specified type.getObjectsAsStream(Class<?> clazz) Gets a sequential Stream over all the objects in this context (and thus in the sub contexts) that are of the specified type.Gets an object in this context chosen at random from a uniform distribution.getRandomObjects(Class<? extends T> clazz, long count) Gets an iterable over a collection of objects chosen at random.getRandomObjectsAsStream(Class<? extends T> clazz, long count) Gets a sequential Stream over a collection of objects chosen at random.booleanremoveAll(Collection<?> c) protected booleanremoveInternal(Object obj) booleanretainAll(Collection<?> c) protected intMethods inherited from class repast.simphony.context.AbstractContext
add, addContextListener, addProjection, addSubContext, addValueLayer, clear, contains, eventOccured, findContext, findParent, fireAddContextEvent, fireRemoveEvent, fireSubContextAdded, fireSubContextRemoved, getAgentLayer, getAgentTypes, getContextListeners, getId, getProjection, getProjection, getProjections, getProjections, getSubContext, getSubContexts, getTypeID, getValueLayer, getValueLayers, handleRemove, hasSubContext, iterator, query, remove, removeContextListener, removeProjection, removeSubContext, removeValueLayer, setId, setTypeID, sizeMethods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
objectMap
-
allObjs
-
-
Constructor Details
-
SmallDefaultContext
public SmallDefaultContext() -
SmallDefaultContext
-
SmallDefaultContext
-
-
Method Details
-
containsInternal
- Specified by:
containsInternalin classAbstractContext<T>
-
iteratorInternal
- Specified by:
iteratorInternalin classAbstractContext<T>
-
sizeInternal
protected int sizeInternal()- Specified by:
sizeInternalin classAbstractContext<T>
-
addInternal
- Specified by:
addInternalin classAbstractContext<T>
-
removeInternal
- Specified by:
removeInternalin classAbstractContext<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Overrides:
removeAllin classAbstractCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Overrides:
retainAllin classAbstractCollection<T>
-
getObjects
Gets a IndexedIterable over all the objects in this context (and thus in the sub contexts) that are of the specified type.- Parameters:
clazz- the type of objects to return- Returns:
- a IndexedIterable over all the objects in this context (and thus in the sub contexts) that are of the specified type.
-
getObjectsAsStream
Gets a sequential Stream over all the objects in this context (and thus in the sub contexts) that are of the specified type.- Parameters:
clazz- the type of objects to return- Returns:
- a Stream over all the objects in this context (and thus in the sub contexts) that are of the specified type. The Stream is sequential.
-
getRandomObjectsAsStream
Gets a sequential Stream over a collection of objects chosen at random. The number of objects is determined by the specified count and the type of objects by the specified class. If the context contains fewer objects than the specified count, all the appropriate objects in the context will be returned.If this is repeatedly called with a count equal to the number of objects in the context, the iteration order will be shuffled each time.
- Parameters:
clazz- the class of the objects to returncount- the number of random objects to return- Returns:
- a sequential Stream over a collection of random objects
-
getRandomObjects
Gets an iterable over a collection of objects chosen at random. The number of objects is determined by the specified count and the type of objects by the specified class. If the context contains fewer objects than the specified count, all the appropriate objects in the context will be returned. If this is repeatedly called with a count equal to the number of objects in the context, the iteration order will be shuffled each time.- Parameters:
clazz- the class of the objects to returncount- the number of random objects to return- Returns:
- an iterable over a collection of random objects
-
getRandomObject
Gets an object in this context chosen at random from a uniform distribution.- Returns:
- an object in this context chosen at random from a uniform distribution.
-