public abstract class FilteredTraverserBase<T,Self extends FilteredTraverserBase<T,Self>>
extends java.lang.Object
implements java.lang.Iterable<T>
Modifier and Type | Class and Description |
---|---|
static class |
FilteredTraverserBase.EdgeFilter<T> |
protected static class |
FilteredTraverserBase.Meta<T> |
Modifier | Constructor and Description |
---|---|
protected |
FilteredTraverserBase(FilteredTraverserBase.Meta<T> meta) |
Modifier and Type | Method and Description |
---|---|
JBIterable<T> |
bfsTraversal() |
JBIterable<T> |
biOrderDfsTraversal() |
Self |
cached()
Configures the traverser to cache its structure.
|
JBIterable<T> |
children(T node)
Returns raw children of the specified node as seen by this traverser.
|
Self |
expand(Condition<? super T> c)
Restricts the nodes that can have children by the specified condition.
|
Self |
expandAndFilter(Condition<? super T> c) |
Self |
expandAndSkip(Condition<? super T> c) |
<C> JBIterable<C> |
filter(java.lang.Class<C> type) |
Self |
filter(Condition<? super T> c) |
Self |
forceDisregard(Condition<? super T> c)
Excludes the nodes by the specified condition while keeping their edges.
|
Self |
forceIgnore(Condition<? super T> c)
Excludes the nodes by the specified condition from any traversal completely.
|
T |
getRoot()
Not supported if
mapImpl(Function) is applied. |
java.lang.Iterable<? extends T> |
getRoots()
Not supported if
mapImpl(Function) is applied. |
Function<? super T,? extends java.lang.Iterable<? extends T>> |
getTree() |
Self |
interceptTraversal(Function<? super TreeTraversal,? extends TreeTraversal> transform)
Intercepts and alters traversal just before the walking.
|
java.util.Iterator<T> |
iterator() |
protected <S,SelfS extends FilteredTraverserBase<S,?>> |
mapImpl(Function<? super T,? extends S> function)
Returns a tree traverser that applies
function to each element of this traverser. |
protected <S,SelfS extends FilteredTraverserBase<S,?>> |
mapImpl(Function<? super T,? extends S> function,
Function<? super S,? extends T> reverse)
Returns a tree traverser that applies
function to each element of this traverser. |
protected abstract Self |
newInstance(FilteredTraverserBase.Meta<T> meta) |
Self |
onRange(Condition<? super T> rangeCondition)
Configures the traverser to expand and return the nodes within the range only.
|
JBIterable<T> |
postOrderDfsTraversal() |
JBIterable<T> |
preOrderDfsTraversal() |
Self |
regard(Condition<? super T> c)
Restricts the nodes that can be children by the specified condition while keeping the edges.
|
Self |
reset()
Clears expand, regard and filter conditions, traversal while keeping roots and "forced" properties.
|
java.util.List<T> |
toList() |
java.util.Set<T> |
toSet() |
java.lang.String |
toString() |
JBIterable<T> |
tracingBfsTraversal() |
JBIterable<T> |
traverse() |
JBIterable<T> |
traverse(TreeTraversal traversal) |
Self |
unique()
Configures the traverser to skip already visited nodes.
|
Self |
unique(Function<? super T,java.lang.Object> identity)
Configures the traverser to skip already visited nodes.
|
Self |
withRoot(T root) |
Self |
withRoots(java.lang.Iterable<? extends T> roots) |
Self |
withRoots(T... roots) |
Self |
withTraversal(TreeTraversal type) |
protected FilteredTraverserBase(FilteredTraverserBase.Meta<T> meta)
public final T getRoot()
mapImpl(Function)
is applied.public final java.lang.Iterable<? extends T> getRoots()
mapImpl(Function)
is applied.public final java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
protected abstract Self newInstance(FilteredTraverserBase.Meta<T> meta)
public final JBIterable<T> traverse(TreeTraversal traversal)
public final JBIterable<T> traverse()
public final JBIterable<T> biOrderDfsTraversal()
public final JBIterable<T> preOrderDfsTraversal()
public final JBIterable<T> postOrderDfsTraversal()
public final JBIterable<T> bfsTraversal()
public final JBIterable<T> tracingBfsTraversal()
public final Self reset()
forceIgnore(Condition)
,
forceDisregard(Condition)
public final Self withTraversal(TreeTraversal type)
public final Self expand(Condition<? super T> c)
public final Self regard(Condition<? super T> c)
public final <C> JBIterable<C> filter(java.lang.Class<C> type)
public final Self unique()
reset()
call.unique(Function)
,
TreeTraversal.unique()
public final Self unique(Function<? super T,java.lang.Object> identity)
reset()
call.TreeTraversal.unique(Function)
public final Self cached()
reset()
call.TreeTraversal#cached()
public Self onRange(Condition<? super T> rangeCondition)
reset()
call.TreeTraversal.onRange(Condition)
public final Self forceIgnore(Condition<? super T> c)
reset()
call.expand(Condition)
,
filter(Condition)
,
reset()
public final Self forceDisregard(Condition<? super T> c)
reset()
call.regard(Condition)
,
reset()
public final Self interceptTraversal(Function<? super TreeTraversal,? extends TreeTraversal> transform)
reset()
call.unique()
,
onRange(Condition)
protected <S,SelfS extends FilteredTraverserBase<S,?>> SelfS mapImpl(Function<? super T,? extends S> function, Function<? super S,? extends T> reverse)
function
to each element of this traverser.
A reverse transform is required if available, otherwise use mapImpl(Function)
.
Subclasses shall provide their own public method to get a more strict return type.JBTreeTraverser.map(Function)
protected <S,SelfS extends FilteredTraverserBase<S,?>> SelfS mapImpl(Function<? super T,? extends S> function)
function
to each element of this traverser.
The required reverse transform, a hash map, is built internally while traversing.
Prefer mapImpl(Function, Function)
if a cheap reverse transform is available.
Subclasses shall provide their own public method to get a more strict return type.JBTreeTraverser.map(Function, Function)
public final JBIterable<T> children(T node)
mapImpl(Function)
is applied.public final java.util.List<T> toList()
public final java.util.Set<T> toSet()
public java.lang.String toString()
toString
in class java.lang.Object