|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.ajaest.data.auxi.OrderedSequenceTree<S,E>
S
- the class of the sequence objectsE
- the class of the stored nodes objectspublic class OrderedSequenceTree<S,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. This class can use either Arraylist
or LinkedList
implementations for final nodes list. It's recommended to use
Arraylist
implementation for fixed trees and LinkedList
implementation for dynamic trees.
Field Summary | |
---|---|
private java.util.List<E> |
finalNodes
|
private OrderedSequenceTree<S,E> |
parent
|
private S |
sequenceValue
|
private java.util.Map<S,OrderedSequenceTree<S,E>> |
subtrees
|
Constructor Summary | |
---|---|
OrderedSequenceTree(boolean linked)
Creates a ordered sequence tree using either Arraylist or LinkedList implementation for final nodes list. |
Method Summary | |
---|---|
boolean |
addFinalNode(E node)
Appends the specified element to the end of this list. |
void |
addSubTree(S sequenceValue,
OrderedSequenceTree<S,E> subtree)
Adds a subtree to this tree using either provided sequenceValue
or subtree.sequenceValue . |
java.util.List<E> |
getFinalNodes()
|
OrderedSequenceTree<S,E> |
getParent()
|
S |
getSequenceValue()
|
java.util.Map<S,OrderedSequenceTree<S,E>> |
getSubTrees()
Returns an unmodifiable map that maps subtrees from this tree by his sequence value. |
boolean |
removeFinalNode(E node)
Removes the first occurrence of the specified element from this list, if it is present. |
E |
removeFinalNode(int index)
Removes the element at the specified position in this list. |
OrderedSequenceTree<S,E> |
removeSubTree(S sequenceValue)
Removes the mapping for the specified key from this map if present. |
java.util.List<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. |
E |
setFinalNode(int index,
E element)
Replaces the element at the specified position in this list with the specified element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private OrderedSequenceTree<S,E> parent
private S sequenceValue
private java.util.Map<S,OrderedSequenceTree<S,E>> subtrees
private java.util.List<E> finalNodes
Constructor Detail |
---|
public OrderedSequenceTree(boolean linked)
Arraylist
or LinkedList
implementation for final nodes list. It's recommended to use
Arraylist
implementations for fixed trees and LinkedList
implementation for dynamic trees.
linked
- if it's true, object will use LinkedList
implementation. Object will use ArrayList
implementation if it's false.Method Detail |
---|
public java.util.Map<S,OrderedSequenceTree<S,E>> getSubTrees()
public java.util.List<E> getFinalNodes()
public S getSequenceValue()
public OrderedSequenceTree<S,E> getParent()
public void addSubTree(S sequenceValue, OrderedSequenceTree<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 E setFinalNode(int index, E element)
index
- index of the element to replaceelement
- element to be stored at the specified position
java.lang.IndexOutOfBoundsException
public boolean addFinalNode(E node)
node
- element to be appended to this list
Collection.add(E)
)public OrderedSequenceTree<S,E> removeSubTree(S sequenceValue)
sequenceValue
- key whose mapping is to be removed from the map
public E removeFinalNode(int index)
index
- the index of the element to be removed
java.lang.IndexOutOfBoundsException
public boolean removeFinalNode(E node)
node
- element to be removed from this list, if present
public java.util.List<E> search(java.util.List<S> sequence)
sequence
- sequence to be searched
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |