java.lang.Object
java.util.Spliterators.AbstractSpliterator<V>
org.jhotdraw8.collection.enumerator.AbstractEnumerator<V>
org.jhotdraw8.graph.iterator.BfsDfsVertexSpliterator<V>
- Type Parameters:
V- the vertex data type
- All Implemented Interfaces:
Spliterator<V>,BareEnumerator<V>,Enumerator<V>
Enumerates vertices in a graph starting from a root vertex in
breadth-first-order or in depth-first-order.
References:
- Robert Sedgewick, Kevin Wayne. (2011)
- Algorithms, 4th Edition. Chapter 4. Algorithm 4.1 Depth-First Search; Algorithm 4.2. Breadth-First Search. math.cmu.edu
- Author:
- Werner Randelshofer
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jhotdraw8.collection.enumerator.Enumerator
Enumerator.OfDouble, Enumerator.OfInt, Enumerator.OfLongNested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
Fields inherited from class org.jhotdraw8.collection.enumerator.AbstractEnumerator
currentFields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsConstructorDescriptionBfsDfsVertexSpliterator(@NonNull Function<V, Iterable<V>> nextFunction, @NonNull V root, boolean dfs) Creates a new instance.BfsDfsVertexSpliterator(@NonNull Function<V, Iterable<V>> nextFunction, @NonNull V root, @NonNull AddToSet<V> visited, boolean dfs) Creates a new instance. -
Method Summary
Methods inherited from class org.jhotdraw8.collection.enumerator.AbstractEnumerator
currentMethods inherited from class java.util.Spliterators.AbstractSpliterator
characteristics, estimateSize, trySplitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.collection.enumerator.Enumerator
tryAdvanceMethods inherited from interface java.util.Spliterator
characteristics, estimateSize, forEachRemaining, getComparator, getExactSizeIfKnown, hasCharacteristics, trySplit
-
Constructor Details
-
BfsDfsVertexSpliterator
public BfsDfsVertexSpliterator(@NonNull Function<V, Iterable<V>> nextFunction, @NonNull V root, boolean dfs) Creates a new instance.- Parameters:
nextFunction- a function that returns the next vertices for a given vertexroot- the root vertexdfs- whether to enumerate depth-first instead of breadth-first
-
BfsDfsVertexSpliterator
public BfsDfsVertexSpliterator(@NonNull Function<V, Iterable<V>> nextFunction, @NonNull V root, @NonNull AddToSet<V> visited, boolean dfs) Creates a new instance.- Parameters:
nextFunction- a function that returns the next vertices for a given vertexroot- the root vertexvisited- a function that adds a provided vertex to a set, and returns true if the vertex was not in the set. If the graph is known to be a tree, the function can always return true.dfs- whether to enumerate depth-first instead of breadth-first
-
-
Method Details
-
moveNext
public boolean moveNext()
-