Package repast.simphony.util.collections
Class CollectionUtils
- java.lang.Object
-
- repast.simphony.util.collections.CollectionUtils
-
public class CollectionUtils extends Object
Utilities for working with collections of many types. This includes search, map(collection, function) functionality and so forth.- Author:
- Jerry Vos
-
-
Constructor Summary
Constructors Constructor Description CollectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>
asList(Iterator iter)
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.
-
-
-
Method Detail
-
breadthFirstMap
public 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. 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
-
-