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 Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • 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 the Traverser.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 returning RuleResult#INVALID_CONTINUE.

      Parameters:
      visitor - the executor which receives the objects from the traverser
      traverser - the object handles gathering and returning the objects that will be passed to the Executor
      root - 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 the Traverser.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 Executor
      root - the object to begin the traversal with
    • asList

      public static <T> List<T> asList(Iterator iter)