net.ajaest.lib.data
Class SequenceEnumTree<S extends java.lang.Enum<S>,E>

java.lang.Object
  extended by net.ajaest.lib.data.SequenceTree<S,E>
      extended by net.ajaest.lib.data.SequenceEnumTree<S,E>
Type Parameters:
S - the class of the sequence objects
E - the class of the stored nodes objects
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Iterable<SequenceTree<S,E>>

public class SequenceEnumTree<S extends java.lang.Enum<S>,E>
extends SequenceTree<S,E>
implements java.io.Externalizable

Search tree by sequence. This class allows to sort a list of node objects using a unique sequence an enumeration elements. Compared to SequenceTree, this class is likely to be faster provided it uses EnumMap implementation to look for child nodes.

Every level of the tree represents all the node objects that can be retrieved through the same enum sequence. 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.

You must be aware that the node circularity of the tree isn't checked when a new node is added. Circular connection between nodes could cause unexpected behavior.

Keep in mind too that the serialization process of an instance of this class won't retrieve information about the parent structure. This means that the readObject() method will always assign null to the parent field of the tree's root node.

Author:
Luis Alfonso Arce González
See Also:
Serialized Form

Field Summary
private  java.lang.Class<S> enumClass
           
private static long serialVersionUID
           
 
Fields inherited from class net.ajaest.lib.data.SequenceTree
finalNodes, isLinked, parent, sequenceValue, serialID, serialIDseed, subtrees
 
Constructor Summary
SequenceEnumTree()
           
SequenceEnumTree(boolean linked, java.lang.Class<S> keyType)
           
 
Method Summary
protected  java.util.Map<S,SequenceTree<S,E>> createSubTreeMapInstance()
           
protected  void readAndAssignToThis(java.io.ObjectInput in)
           
protected  SequenceTree<S,E> readTreeSequentially(java.io.ObjectInput in)
          Parent field is not retrieved
protected  void writeTreeSequentially(java.io.ObjectOutput out, SequenceTree<S,E> ost)
          Parent field is not stored
 
Methods inherited from class net.ajaest.lib.data.SequenceTree
add, add, addFinalNode, addSubTree, equals, exist, getFinalNodes, getParent, getSequenceValue, getSubTree, getSubTrees, hashCode, init, iterator, readExternal, removeFinalNode, removeFinalNode, removeSubTree, search, search, searchFirst, searchFirst, setFinalNode, writeExternal
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

enumClass

private java.lang.Class<S extends java.lang.Enum<S>> enumClass
Constructor Detail

SequenceEnumTree

public SequenceEnumTree()

SequenceEnumTree

public SequenceEnumTree(boolean linked,
                        java.lang.Class<S> keyType)
Method Detail

createSubTreeMapInstance

protected java.util.Map<S,SequenceTree<S,E>> createSubTreeMapInstance()
Overrides:
createSubTreeMapInstance in class SequenceTree<S extends java.lang.Enum<S>,E>

readTreeSequentially

protected SequenceTree<S,E> readTreeSequentially(java.io.ObjectInput in)
                                                                    throws java.io.IOException,
                                                                           java.lang.ClassNotFoundException
Description copied from class: SequenceTree
Parent field is not retrieved

Overrides:
readTreeSequentially in class SequenceTree<S extends java.lang.Enum<S>,E>
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeTreeSequentially

protected void writeTreeSequentially(java.io.ObjectOutput out,
                                     SequenceTree<S,E> ost)
                              throws java.io.IOException
Description copied from class: SequenceTree
Parent field is not stored

Overrides:
writeTreeSequentially in class SequenceTree<S extends java.lang.Enum<S>,E>
Throws:
java.io.IOException

readAndAssignToThis

protected void readAndAssignToThis(java.io.ObjectInput in)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Overrides:
readAndAssignToThis in class SequenceTree<S extends java.lang.Enum<S>,E>
Throws:
java.io.IOException
java.lang.ClassNotFoundException