Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.index.tree
Class TreeIndexPath<E extends Entry>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.index.tree.TreeIndexPath<E>
Type Parameters:
E - the type of Entry used in the index

public class TreeIndexPath<E extends Entry>
extends Object

Represents a path to a node in an index structure.

Author:
Elke Achtert

Field Summary
private  TreeIndexPathComponent<E> lastPathComponent
          Last path component.
private  TreeIndexPath<E> parentPath
          Path representing the parent, null if lastPathComponent represents the root.
 
Constructor Summary
  TreeIndexPath(List<TreeIndexPathComponent<E>> path)
          Constructs a path from a list of path components, uniquely identifying the path from the root of the index to a specific node.
protected TreeIndexPath(List<TreeIndexPathComponent<E>> path, int length)
          Constructs a new IndexPath with the identified path components of length length.
protected TreeIndexPath(TreeIndexPath<E> parent, TreeIndexPathComponent<E> lastElement)
          Constructs a new IndexPath, which is the path identified by parent ending in lastElement.
  TreeIndexPath(TreeIndexPathComponent<E> singlePath)
          Constructs a IndexPath containing only a single element.
 
Method Summary
 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 the two index paths are of the same length, and contain the same components (.equals), false otherwise.
 TreeIndexPathComponent<E> getLastPathComponent()
          Returns the last component of this path.
 TreeIndexPath<E> getParentPath()
          Returns a path containing all the elements of this object, except the last path component.
 List<TreeIndexPathComponent<E>> getPath()
          Returns an ordered list of IndexPathComponents containing the components of this IndexPath.
 TreeIndexPathComponent<E> getPathComponent(int element)
          Returns the path component at the specified index.
 int getPathCount()
          Returns the number of elements in the path.
 int hashCode()
          Returns the hash code for this index path.
 boolean isDescendant(TreeIndexPath<E> aIndexPath)
          Returns true if aIndexPath is a descendant of this IndexPath.
 TreeIndexPath<E> pathByAddingChild(TreeIndexPathComponent<E> child)
          Returns a new path containing all the elements of this object plus child.
 String toString()
          Returns a string that displays the components of this index path.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

parentPath

private TreeIndexPath<E extends Entry> parentPath
Path representing the parent, null if lastPathComponent represents the root.


lastPathComponent

private TreeIndexPathComponent<E extends Entry> lastPathComponent
Last path component.

Constructor Detail

TreeIndexPath

public TreeIndexPath(List<TreeIndexPathComponent<E>> path)
Constructs a path from a list of path components, uniquely identifying the path from the root of the index to a specific node. The first element in the path is the root of the index, the last node is the node identified by the path.

Parameters:
path - a list of IndexPathComponents representing the path to a node

TreeIndexPath

public TreeIndexPath(TreeIndexPathComponent<E> singlePath)
Constructs a IndexPath containing only a single element. This is usually used to construct a IndexPath for the the root of the index.

Parameters:
singlePath - a IndexPathComponent representing the path to a node

TreeIndexPath

protected TreeIndexPath(TreeIndexPath<E> parent,
                        TreeIndexPathComponent<E> lastElement)
Constructs a new IndexPath, which is the path identified by parent ending in lastElement.

Parameters:
parent - the parent path
lastElement - the last path component

TreeIndexPath

protected TreeIndexPath(List<TreeIndexPathComponent<E>> path,
                        int length)
Constructs a new IndexPath with the identified path components of length length.

Parameters:
path - the whole path
length - the length of the newly created index path
Method Detail

getPath

public List<TreeIndexPathComponent<E>> getPath()
Returns an ordered list of IndexPathComponents containing the components of this IndexPath. The first element (index 0) is the root.

Returns:
an array of IndexPathComponent representing the IndexPath

getLastPathComponent

public TreeIndexPathComponent<E> getLastPathComponent()
Returns the last component of this path.

Returns:
the IndexPathComponent at the end of the path

getPathCount

public int getPathCount()
Returns the number of elements in the path.

Returns:
an int giving a count of items the path

getPathComponent

public TreeIndexPathComponent<E> getPathComponent(int element)
Returns the path component at the specified index.

Parameters:
element - an int specifying an element in the path, where 0 is the first element in the path
Returns:
the Object at that index location
Throws:
IllegalArgumentException - if the index is beyond the length of the path

equals

public 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 the two index paths are of the same length, and contain the same components (.equals), false otherwise.

Overrides:
equals in class Object
See Also:
TreeIndexPathComponent.equals(Object)

hashCode

public int hashCode()
Returns the hash code for this index path. The hash code of a TreeIndexPath is defined to be the hash code of the last component in the path.

Overrides:
hashCode in class Object
Returns:
the hash code of the last component in the index path

isDescendant

public boolean isDescendant(TreeIndexPath<E> aIndexPath)
Returns true if aIndexPath is a descendant of this IndexPath. A IndexPath P1 is a descendent of a IndexPath P2 if P1 contains all of the components that make up P2's path. For example, if this object has the path [a, b], and aIndexPath has the path [a, b, c], then aIndexPath is a descendant of this object. However, if aIndexPath has the path [a], then it is not a descendant of this object.

Parameters:
aIndexPath - the index path to be tested
Returns:
true if aIndexPath is a descendant of this path

pathByAddingChild

public TreeIndexPath<E> pathByAddingChild(TreeIndexPathComponent<E> child)
Returns a new path containing all the elements of this object plus child. child will be the last element of the newly created IndexPath. This will throw a NullPointerException if child is null.

Parameters:
child - the last element of the newly created IndexPath
Returns:
a new path containing all the elements of this object plus child

getParentPath

public TreeIndexPath<E> getParentPath()
Returns a path containing all the elements of this object, except the last path component.

Returns:
a path containing all the elements of this object, except the last path component

toString

public String toString()
Returns a string that displays the components of this index path.

Overrides:
toString in class Object
Returns:
a string representation of the components of this index path

Release 0.2 (2009-07-06_1820)