Package repast.simphony.util.collections
Class CollectionUtils
java.lang.Object
repast.simphony.util.collections.CollectionUtils
Utilities for working with collections of many types. This includes search, map(collection,
function) functionality and so forth.
- Author:
- Jerry Vos
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
static <T> void
breadthFirstMap
(Executor<T> visitor, Traverser<T> traverser, T root) Performs a breadth-first traversal applying the given executor to the objects returned by the traverser.static <T> T
breadthFirstSearch
(org.apache.commons.collections15.Predicate<T> checker, Traverser<T> traverser, T root) Performs a breadth-first traversal, applying the given rule to the objects returned by the traverser.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
breadthFirstMap
Performs a breadth-first traversal applying the given executor to the objects returned by the traverser. It is up to the traverser to handle how the objects are returned and to prevent repeated execution on the same nodes (if so desired). For example, it is up to the traverser to not return the same node in a graph multiple times, this method performs no checks for this type of situation. Note: This passes null to theTraverser.getSuccessors(E, E)
method for the value of the previous node. This is implemented as a call to#breadthFirstSearch(Executor, Traverser, T)
with the calling the Executor and always returningRuleResult#INVALID_CONTINUE
.- Parameters:
visitor
- the executor which receives the objects from the traversertraverser
- the object handles gathering and returning the objects that will be passed to the Executorroot
- the object to begin the traversal with
-
breadthFirstSearch
public static <T> T breadthFirstSearch(org.apache.commons.collections15.Predicate<T> checker, Traverser<T> traverser, T root) Performs a breadth-first traversal, applying the given rule to the objects returned by the traverser. It is up to the traverser to handle how the objects are returned and to prevent repeated execution on the same nodes (if so desired). For example, it is up to the traverser to not return the same node in a graph multiple times, this method performs no checks for this type of situation. Note: This passes null to theTraverser.getSuccessors(E, E)
method for the value of the previous node.- Parameters:
checker
-traverser
- the object handles gathering and returning the objects that will be passed to the Executorroot
- the object to begin the traversal with
-
asList
-