Package de.xima.fc.common.tree
Class TreeIteration
- java.lang.Object
 - 
- de.xima.fc.common.tree.TreeIteration
 
 
- 
public final class TreeIteration extends Object
An iterable that iterates over a tree-like graph in pre-order, starting at a given node. Throws an exception in case the graph is not a tree, thus also preventing endless cycles when the graph is cyclic.Assume the following tree:
- a
       
- a1
 - a2
             
- a21
 - a22
 
 
 - b
       
- b1
 - b2
 
 
- a
 - a1
 - a2
 - a21
 - a22
 - b
 - b1
 - b2
 
- Since:
 - 8.4.0
 - Author:
 - XIMA MEDIA GmbH
 
 - a
       
 
- 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <TItem,TIdentifier>
Iterable<TItem>preOrderIterable(Iterable<? extends TItem> startItems, ITreeAccessor<TItem,TIdentifier> treeAccessor)Creates an iterable over the tree's nodes in pre-order, starting at the given items.static <TItem,TIdentifier>
Iterable<TItem>preOrderIterable(Iterable<? extends TItem> startItems, ITreeAccessor<TItem,TIdentifier> treeAccessor, long flags)Creates an iterable over the tree's nodes in pre-order, starting at the given items.static <TItem,TIdentifier>
Iterable<TItem>preOrderIterable(TItem startNode, ITreeAccessor<TItem,TIdentifier> treeAccessor)Creates an iterable over the tree's nodes in pre-order, starting at the given item.static <TItem,TIdentifier>
Iterable<TItem>preOrderIterable(TItem startNode, ITreeAccessor<TItem,TIdentifier> treeAccessor, long flags)Creates an iterable over the tree's nodes in pre-order, starting at the given item. 
 - 
 
- 
- 
Method Detail
- 
preOrderIterable
public static <TItem,TIdentifier> Iterable<TItem> preOrderIterable(TItem startNode, ITreeAccessor<TItem,TIdentifier> treeAccessor)
Creates an iterable over the tree's nodes in pre-order, starting at the given item.- Type Parameters:
 TItem- Type of the items in the tree.TIdentifier- Type of the identifier that identifiers the items in the tree.- Parameters:
 startNode- Node where to start the traversal. This item is included in the traversal.treeAccessor- Handler for accessing the children of a node, and its identifier.
 
- 
preOrderIterable
public static <TItem,TIdentifier> Iterable<TItem> preOrderIterable(TItem startNode, ITreeAccessor<TItem,TIdentifier> treeAccessor, long flags)
Creates an iterable over the tree's nodes in pre-order, starting at the given item.- Type Parameters:
 TItem- Type of the items in the tree.TIdentifier- Type of the identifier that identifiers the items in the tree.- Parameters:
 startNode- Node where to start the traversal.treeAccessor- Handler for accessing the children of a node, and its identifier.flags- Flags that affect the iteration, seeTreeIterationFlagfor details.
 
- 
preOrderIterable
public static <TItem,TIdentifier> Iterable<TItem> preOrderIterable(Iterable<? extends TItem> startItems, ITreeAccessor<TItem,TIdentifier> treeAccessor)
Creates an iterable over the tree's nodes in pre-order, starting at the given items.- Parameters:
 startItems- Root items where to start the traversal. These items are included in the traversal.treeAccessor- Handler for accessing the children of a node, and its identifier.
 
- 
preOrderIterable
public static <TItem,TIdentifier> Iterable<TItem> preOrderIterable(Iterable<? extends TItem> startItems, ITreeAccessor<TItem,TIdentifier> treeAccessor, long flags)
Creates an iterable over the tree's nodes in pre-order, starting at the given items.- Parameters:
 startItems- Root items where to start the traversal.treeAccessor- Handler for accessing the children of a node, and its identifier.flags- Flags that affect the iteration, seeTreeIterationFlagfor details.
 
 - 
 
 -