INFORMATION - Information carry typepublic class Tree<INFORMATION>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
Tree.ComparatorTree<INFO>
Comparator used to compare 2 branches on using there carry information
|
static class |
Tree.SearchMode
Method of search inside the tree.
|
static interface |
Tree.TestFoundListener<INFO>
Listener called each tile we test an information to know if this information is the searched one.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.ArrayList<Tree<INFORMATION>> |
branches
Tree branches
|
private Tree.ComparatorTree<INFORMATION> |
comparatorTree
Comparator used to compare 2 branches
|
(package private) INFORMATION |
information
Carried information
|
private Tree<INFORMATION> |
trunk
Trunk that contains this tree
|
| Modifier | Constructor and Description |
|---|---|
|
Tree(INFORMATION information)
Create a new instance of Tree
|
private |
Tree(Tree<INFORMATION> trunk,
INFORMATION information)
Create a new instance of Tree
|
| Modifier and Type | Method and Description |
|---|---|
Tree<INFORMATION> |
addBranch(INFORMATION information)
Add a branch to the tree
|
Tree<INFORMATION> |
addBranchSorted(INFORMATION information,
java.util.Comparator<INFORMATION> comparator)
Add a branch to the tree if ordered way.
|
private void |
collectLeafs(java.util.List<Tree<INFORMATION>> list)
Collect all tree leafs and put them in a list
|
int |
computeWeight()
Compute the branch weight.
|
void |
exchangeBranch(int index1,
int index2)
Exchange 2 branch
|
Tree<INFORMATION> |
getBranch(int index)
Obtain a branch
|
EnumerationIterator<Tree<INFORMATION>> |
getBranches()
List of branches
|
int |
getIndexInTrunk()
Compute the index of this tree in its trunk parent.
|
INFORMATION |
getInformation()
Carried information
|
Tree<INFORMATION> |
getMainTrunk()
Get tree main trunk.
|
Tree<INFORMATION> |
getTrunk()
Trunk parent
|
boolean |
isLeaf()
Indicates if the tree is a leaf.
|
java.util.List<Tree<INFORMATION>> |
listOfLeafs()
Collect all the tree leaf, no matter how depth they are
|
int |
numberOfBranch()
Number branch of the tree
|
Tree<INFORMATION> |
removeBranch(int index)
Remove a branch
|
Tree<INFORMATION> |
searchBranch(Tree.TestFoundListener<INFORMATION> testFoundListener,
Tree.SearchMode searchMode,
boolean remove)
Search a branch by its information
|
private Tree<INFORMATION> |
searchLeftToRightDepth(Tree.TestFoundListener<INFORMATION> testFoundListener)
Search a branch in left to right depth rule.
|
private Tree<INFORMATION> |
searchLeftToRightHigh(Tree.TestFoundListener<INFORMATION> testFoundListener)
Search a branch in left to right high rule.
|
private Tree<INFORMATION> |
searchRightToLeftDepth(Tree.TestFoundListener<INFORMATION> testFoundListener)
Search a branch in right to left depth rule.
|
private Tree<INFORMATION> |
searchRightToLeftHigh(Tree.TestFoundListener<INFORMATION> testFoundListener)
Search a branch in right to left high rule.
|
void |
sortBranches(java.util.Comparator<INFORMATION> comparator)
Sort branches of the tree
|
private final java.util.ArrayList<Tree<INFORMATION>> branches
private final Tree.ComparatorTree<INFORMATION> comparatorTree
private final Tree<INFORMATION> trunk
final INFORMATION information
private Tree(Tree<INFORMATION> trunk, INFORMATION information)
trunk - Trunk parentinformation - Information carrypublic Tree(INFORMATION information)
information - Information carray (Musn't be null)private void collectLeafs(java.util.List<Tree<INFORMATION>> list)
list - List where put collected leafsprivate Tree<INFORMATION> searchLeftToRightDepth(Tree.TestFoundListener<INFORMATION> testFoundListener)
Tree.SearchMode, the order here is :
Tree.SearchMode.LEFT_TO_RIGHT_DEPTHtestFoundListener - Tester of information searchnull if not foundprivate Tree<INFORMATION> searchLeftToRightHigh(Tree.TestFoundListener<INFORMATION> testFoundListener)
Tree.SearchMode, the order here is :
Tree.SearchMode.LEFT_TO_RIGHT_HIGHtestFoundListener - Tester of information searchnull if not foundprivate Tree<INFORMATION> searchRightToLeftDepth(Tree.TestFoundListener<INFORMATION> testFoundListener)
Tree.SearchMode, the order here is :
Tree.SearchMode.RIGHT_TO_LEFT_DEPTHtestFoundListener - Tester of information searchnull if not foundprivate Tree<INFORMATION> searchRightToLeftHigh(Tree.TestFoundListener<INFORMATION> testFoundListener)
Tree.SearchMode, the order here is :
Tree.SearchMode.RIGHT_TO_LEFT_HIGHtestFoundListener - Tester of information searchnull if not foundpublic Tree<INFORMATION> addBranch(INFORMATION information)
information - Information to put on the branchpublic Tree<INFORMATION> addBranchSorted(INFORMATION information, java.util.Comparator<INFORMATION> comparator)
sortBranches(Comparator)information - Information to put on the branchcomparator - Comparator to use for know the orderpublic int computeWeight()
public void exchangeBranch(int index1,
int index2)
index1 - Index of branch 1index2 - Index of branch 2public Tree<INFORMATION> getBranch(int index)
index - Branch indexpublic EnumerationIterator<Tree<INFORMATION>> getBranches()
public int getIndexInTrunk()
public INFORMATION getInformation()
public Tree<INFORMATION> getMainTrunk()
public Tree<INFORMATION> getTrunk()
public boolean isLeaf()
true if the tree is a leafpublic java.util.List<Tree<INFORMATION>> listOfLeafs()
public int numberOfBranch()
public Tree<INFORMATION> removeBranch(int index)
index - Branch indexpublic Tree<INFORMATION> searchBranch(Tree.TestFoundListener<INFORMATION> testFoundListener, Tree.SearchMode searchMode, boolean remove)
testFoundListener - Tester to know if an information is the searched onesearchMode - Way to search in the tree. See Tree.SearchModeremove - Indicates if the searched branch have to be removed from its trunknull if not foundpublic void sortBranches(java.util.Comparator<INFORMATION> comparator)
comparator - Comparator to know the order