|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.persistent.AbstractPage<N>
de.lmu.ifi.dbs.elki.index.tree.AbstractNode<N,E>
N
- the type of Node used in the indexE
- the type of Entry used in the indexpublic abstract class AbstractNode<N extends AbstractNode<N,E>,E extends Entry>
Abstract superclass for nodes in an tree based index structure.
Field Summary | |
---|---|
protected Class<E> |
eclass
Entry class. |
protected E[] |
entries
The entries (children) of this node. |
protected boolean |
isLeaf
Indicates whether this node is a leaf node. |
protected int |
numEntries
The number of entries in this node. |
Constructor Summary | |
---|---|
AbstractNode()
Empty constructor for Externalizable interface. |
|
AbstractNode(PageFile<N> file,
int capacity,
boolean isLeaf,
Class<? super E> eclass)
Creates a new Node with the specified parameters. |
Method Summary | |
---|---|
int |
addDirectoryEntry(E entry)
Adds a new directory entry to this node's children and returns the index of the entry in this node's children array. |
private int |
addEntry(E entry)
Adds the specified entry to the entries array and increases the numEntries counter. |
int |
addLeafEntry(E entry)
Adds a new leaf entry to this node's children and returns the index of the entry in this node's children array. |
Enumeration<TreeIndexPath<E>> |
children(TreeIndexPath<E> parentPath)
Returns an enumeration of the children paths of this node. |
protected abstract N |
createNewDirectoryNode(int capacity)
Creates a new directory node with the specified capacity. |
protected abstract N |
createNewLeafNode(int capacity)
Creates a new leaf node with the specified capacity. |
protected void |
deleteAllEntries()
Deletes all entries in this node. |
boolean |
deleteEntry(int index)
Deletes the entry at the specified index and shifts all entries after the index to left. |
boolean |
equals(Object o)
Returns true if this == o has the value
true or o is not null and o is of the same class as this
instance and super.equals(o) returns true and
both nodes are of the same type (leaf node or directory node) and have
contain the same entries, false otherwise. |
int |
getCapacity()
Returns the capacity of this node (i.e. the length of the entries arrays). |
List<E> |
getEntries()
Returns a list of the entries. |
E |
getEntry(int index)
Returns the entry at the specified index. |
int |
getNumEntries()
Returns the number of entries of this node. |
void |
increaseEntries()
Increases the length of the entries array to entries.length + 1. |
boolean |
isLeaf()
Returns true if this node is a leaf node, false otherwise. |
void |
readExternal(ObjectInput in)
Reads the id of this node, the numEntries and the entries array from the specified stream. |
String |
toString()
Returns a string representation of this node. |
void |
writeExternal(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 de.lmu.ifi.dbs.elki.persistent.AbstractPage |
---|
getFile, getID, hashCode, isDirty, setDirty, setFile, setID |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.persistent.Page |
---|
getID, isDirty, setDirty, setFile, setID |
Field Detail |
---|
protected int numEntries
protected E extends Entry[] entries
protected Class<E extends Entry> eclass
protected boolean isLeaf
Constructor Detail |
---|
public AbstractNode()
public AbstractNode(PageFile<N> file, int capacity, boolean isLeaf, Class<? super E> eclass)
file
- the file storing the indexcapacity
- the capacity (maximum number of entries plus 1 for
overflow) of this nodeisLeaf
- indicates whether this node is a leaf nodeMethod Detail |
---|
public final Enumeration<TreeIndexPath<E>> children(TreeIndexPath<E> parentPath)
Node
children
in interface Node<N extends AbstractNode<N,E>,E extends Entry>
parentPath
- the path to this node
public final int getNumEntries()
Node
getNumEntries
in interface Node<N extends AbstractNode<N,E>,E extends Entry>
public final boolean isLeaf()
Node
isLeaf
in interface Node<N extends AbstractNode<N,E>,E extends Entry>
public final E getEntry(int index)
Node
getEntry
in interface Node<N extends AbstractNode<N,E>,E extends Entry>
index
- the index of the entry to be returned
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
writeExternal
in class AbstractPage<N extends AbstractNode<N,E>>
out
- the stream to write the object to
IOException
- Includes any I/O exceptions that may occurpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
readExternal
in class AbstractPage<N extends AbstractNode<N,E>>
in
- the stream to read data from in order to restore the object
IOException
- if I/O errors occur
ClassNotFoundException
- If the class for an object being restored
cannot be found.public boolean equals(Object o)
true
if this == o
has the value
true
or o is not null and o is of the same class as this
instance and super.equals(o)
returns true
and
both nodes are of the same type (leaf node or directory node) and have
contain the same entries, false
otherwise.
equals
in class AbstractPage<N extends AbstractNode<N,E>>
o
- the object to be tested
AbstractPage.equals(Object)
public final String toString()
toString
in class AbstractPage<N extends AbstractNode<N,E>>
public final int addLeafEntry(E entry)
addLeafEntry
in interface Node<N extends AbstractNode<N,E>,E extends Entry>
entry
- the leaf entry to be added
UnsupportedOperationException
- if entry is not a leaf entry or this
node is not a leaf nodepublic final int addDirectoryEntry(E entry)
addDirectoryEntry
in interface Node<N extends AbstractNode<N,E>,E extends Entry>
entry
- the directory entry to be added
UnsupportedOperationException
- if entry is not a directory entry or
this node is not a directory nodepublic boolean deleteEntry(int index)
index
- the index at which the entry is to be deleted
protected final void deleteAllEntries()
public final void increaseEntries()
public final int getCapacity()
public final List<E> getEntries()
protected abstract N createNewLeafNode(int capacity)
capacity
- the capacity of the new node
protected abstract N createNewDirectoryNode(int capacity)
capacity
- the capacity of the new node
private int addEntry(E entry)
entry
- the entry to be added
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |