|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.ajaest.lib.data.SortedOrderedSequenceTree<S,E>
S
- the class of the sequence objectsE
- the class of the stored nodes objectspublic class SortedOrderedSequenceTree<S,E extends java.lang.Comparable<E>>
Search tree by sequence. This class allows to sort a list of node objects
using a unique sequence of other objects. Every level of the tree represents
all the node objects that have in common a particular list in specific order
of other objects. The list of final nodes is an ordered sequence stored in a
TreeSet
Field Summary | |
---|---|
private java.util.NavigableSet<E> |
finalNodes
|
private SortedOrderedSequenceTree<S,E> |
parent
|
private S |
sequenceValue
|
private java.util.Map<S,SortedOrderedSequenceTree<S,E>> |
subtrees
|
Constructor Summary | |
---|---|
SortedOrderedSequenceTree()
Creates a ordered sequence tree using the object default comparator for final nodes' set |
Method Summary | |
---|---|
void |
add(java.util.List<S> sequence,
E finalNode)
Creates needed sequence tree if necessary in order to add a final node to the tree. |
boolean |
addFinalNode(E node)
Appends the specified element to the end of this list. |
void |
addSubTree(S sequenceValue,
SortedOrderedSequenceTree<S,E> subtree)
Adds a subtree to this tree using either provided sequenceValue
or subtree.sequenceValue . |
boolean |
equals(java.lang.Object obj)
|
boolean |
exists(java.util.List<S> sequence)
Says whether exists or not any final node in this tree referenced by the specified sequence |
java.util.NavigableSet<E> |
getFinalNodes()
|
SortedOrderedSequenceTree<S,E> |
getParent()
|
S |
getSequenceValue()
|
SortedOrderedSequenceTree<S,E> |
getSubTree(S sequenceValue)
Returns the subtree whose sequence value equals the specified one. |
java.util.Map<S,SortedOrderedSequenceTree<S,E>> |
getSubTrees()
Returns an unmodifiable map that maps subtrees from this tree by his sequence value. |
int |
hashCode()
|
boolean |
removeFinalNode(E node)
Removes the first occurrence of the specified element from this list, if it is present. |
SortedOrderedSequenceTree<S,E> |
removeSubTree(S sequenceValue)
Removes the mapping for the specified key from this map if present. |
java.util.NavigableSet<E> |
search(java.util.List<S> sequence)
Does a recursive search along subtrees of this tree in order to get final nodes that matches the specified sequence. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private SortedOrderedSequenceTree<S,E extends java.lang.Comparable<E>> parent
private S sequenceValue
private java.util.Map<S,SortedOrderedSequenceTree<S,E extends java.lang.Comparable<E>>> subtrees
private java.util.NavigableSet<E extends java.lang.Comparable<E>> finalNodes
Constructor Detail |
---|
public SortedOrderedSequenceTree()
Method Detail |
---|
public void add(java.util.List<S> sequence, E finalNode)
sequence.size()==0
, the final node is added to
this tree.
sequence
- the sorting sequencefinalNode
- the final nodepublic java.util.Map<S,SortedOrderedSequenceTree<S,E>> getSubTrees()
public java.util.NavigableSet<E> getFinalNodes()
public SortedOrderedSequenceTree<S,E> getSubTree(S sequenceValue)
sequenceValue
- the sequence value of the requested subtree
public S getSequenceValue()
public SortedOrderedSequenceTree<S,E> getParent()
public void addSubTree(S sequenceValue, SortedOrderedSequenceTree<S,E> subtree)
sequenceValue
or subtree.sequenceValue
. If sequenceValue
don't equals
null
, this value will be used to map the subtree. subtree.sequenceValue
will be used to map the subtree if sequenceValue
equals null
only if subtree.sequenceValue
does not equals null
. If both sequence values equals null
exception will be thrown.
sequenceValue
- order mapping value, if null sequenceValue
will be
usedsubtree
- subtree to be added
java.lang.NullPointerException
- if sequenceValue
and subtree.sequenceValue
are both nullpublic boolean addFinalNode(E node)
node
- element to be appended to this list
Collection.add(E)
)public SortedOrderedSequenceTree<S,E> removeSubTree(S sequenceValue)
sequenceValue
- key whose mapping is to be removed from the map
public boolean removeFinalNode(E node)
node
- element to be removed from this list, if present
public java.util.NavigableSet<E> search(java.util.List<S> sequence)
sequence
- sequence to be searched
public boolean exists(java.util.List<S> sequence)
sequence
- sequence to be checked
search(sequence)
does not returns an empty list,
false otherwisepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |