Package elki.index.tree
Class AbstractNode<E>
- java.lang.Object
-
- elki.persistent.AbstractExternalizablePage
-
- elki.index.tree.AbstractNode<E>
-
- Type Parameters:
E- the type of Entry used in the index
- Direct Known Subclasses:
AbstractMTreeNode,AbstractRStarTreeNode
public abstract class AbstractNode<E> extends AbstractExternalizablePage implements Node<E>
Abstract superclass for nodes in an tree based index structure.- Since:
- 0.1
- Author:
- Elke Achtert
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]entriesThe entries (children) of this node.protected booleanisLeafIndicates whether this node is a leaf node.protected intnumEntriesThe number of entries in this node.
-
Constructor Summary
Constructors Constructor Description AbstractNode()Empty constructor for Externalizable interface.AbstractNode(int capacity, boolean isLeaf)Creates a new Node with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddEntry(E entry)Adds a new entry to this node's children and returns the index of the entry in the children array.java.util.Iterator<IndexTreePath<E>>children(IndexTreePath<E> parentPath)Returns an enumeration of the children paths of this node.voiddeleteAllEntries()Deletes all entries in this node.booleandeleteEntry(int index)Deletes the entry at the specified index and shifts all entries after the index to left.intgetCapacity()Returns the capacity of this node (i.e. the length of the entries arrays).EgetEntry(int index)Returns the entry at the specified index.intgetNumEntries()Returns the number of entries of this node.booleanisLeaf()Returns true if this node is a leaf node, false otherwise.voidreadExternal(java.io.ObjectInput in)Reads the id of this node, the numEntries and the entries array from the specified stream.voidremoveMask(long[] mask)Remove entries according to the given mask.voidsplitByMask(AbstractNode<E> newNode, long[] assignment)Splits the entries of this node into a new node using the given assignmentsvoidsplitTo(AbstractNode<E> newNode, java.util.List<E> sorting, int splitPoint)Redistribute entries according to the given sorting.voidsplitTo(AbstractNode<E> newNode, java.util.List<E> assignmentsToFirst, java.util.List<E> assignmentsToSecond)Splits the entries of this node into a new node using the given assignmentsjava.lang.StringtoString()Returns a string representation of this node.voidwriteExternal(java.io.ObjectOutput out)Calls the super method and writes the id of this node, the numEntries and the entries array to the specified stream.-
Methods inherited from class elki.persistent.AbstractExternalizablePage
equals, getPageID, hashCode, isDirty, setDirty, setPageID
-
-
-
-
Constructor Detail
-
AbstractNode
public AbstractNode()
Empty constructor for Externalizable interface.
-
AbstractNode
public AbstractNode(int capacity, boolean isLeaf)Creates a new Node with the specified parameters.- Parameters:
capacity- the capacity (maximum number of entries plus 1 for overflow) of this nodeisLeaf- indicates whether this node is a leaf node
-
-
Method Detail
-
children
public final java.util.Iterator<IndexTreePath<E>> children(IndexTreePath<E> parentPath)
Description copied from interface:NodeReturns an enumeration of the children paths of this node.
-
getNumEntries
public final int getNumEntries()
Description copied from interface:NodeReturns the number of entries of this node.- Specified by:
getNumEntriesin interfaceNode<E>- Returns:
- the number of entries of this node
-
isLeaf
public final boolean isLeaf()
Description copied from interface:NodeReturns true if this node is a leaf node, false otherwise.
-
getEntry
public final E getEntry(int index)
Description copied from interface:NodeReturns the entry at the specified index.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionCalls the super method and writes the id of this node, the numEntries and the entries array to the specified stream.- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classAbstractExternalizablePage- Parameters:
out- the stream to write the object to- Throws:
java.io.IOException- Includes any I/O exceptions that may occur
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundExceptionReads the id of this node, the numEntries and the entries array from the specified stream.- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classAbstractExternalizablePage- Parameters:
in- the stream to read data from in order to restore the object- Throws:
java.io.IOException- if I/O errors occurjava.lang.ClassNotFoundException- If the class for an object being restored cannot be found.
-
toString
public java.lang.String toString()
Returns a string representation of this node.- Overrides:
toStringin classAbstractExternalizablePage- Returns:
- the type of this node (LeafNode or DirNode) followed by its id
-
addEntry
public final int addEntry(E entry)
Description copied from interface:NodeAdds a new entry to this node's children and returns the index of the entry in the children array. An IllegalStateException will be thrown when inserting leaf entries into directory nodes or conversely.
-
deleteEntry
public boolean deleteEntry(int index)
Deletes the entry at the specified index and shifts all entries after the index to left.- Parameters:
index- the index at which the entry is to be deleted- Returns:
- true id deletion was successful
-
deleteAllEntries
public final void deleteAllEntries()
Deletes all entries in this node.
-
getCapacity
public final int getCapacity()
Returns the capacity of this node (i.e. the length of the entries arrays).- Returns:
- the capacity of this node
-
removeMask
public void removeMask(long[] mask)
Remove entries according to the given mask.- Parameters:
mask- Mask to remove
-
splitTo
public final void splitTo(AbstractNode<E> newNode, java.util.List<E> sorting, int splitPoint)
Redistribute entries according to the given sorting.- Parameters:
newNode- Node to split tosorting- Sorting to usesplitPoint- Split point
-
splitTo
public final void splitTo(AbstractNode<E> newNode, java.util.List<E> assignmentsToFirst, java.util.List<E> assignmentsToSecond)
Splits the entries of this node into a new node using the given assignments- Parameters:
newNode- Node to split toassignmentsToFirst- the assignment to this nodeassignmentsToSecond- the assignment to the new node
-
splitByMask
public final void splitByMask(AbstractNode<E> newNode, long[] assignment)
Splits the entries of this node into a new node using the given assignments- Parameters:
newNode- Node to split toassignment- Assignment mask
-
-