Class Tree.Path

java.lang.Object
io.jenetics.ext.util.Tree.Path
All Implemented Interfaces:
Serializable, Comparable<Tree.Path>
Enclosing interface:
Tree<V,T extends Tree<V,T>>

public static final class Tree.Path extends Object implements Comparable<Tree.Path>, Serializable
This class represents the path to child within a given tree. It allows pointing (and fetch) a tree child.
Since:
4.4
Version:
7.2
See Also:
  • Method Details

    • length

      public int length()
      Return the path length, which is the level of the child this path points to.
      Returns:
      the path length
    • get

      public int get(int index)
      Return the child index at the given index (child level).
      Parameters:
      index - the path index
      Returns:
      the child index at the given child level
      Throws:
      IndexOutOfBoundsException - if the index is not with the range [0, length())
    • toArray

      public int[] toArray()
      Return the path as int[] array.
      Returns:
      the path as int[] array
    • append

      public Tree.Path append(Tree.Path path)
      Appends the given path to this one.
      Parameters:
      path - the path to append
      Returns:
      a new Path with the given path appended
      Throws:
      NullPointerException - if the given path is null
    • compareTo

      public int compareTo(Tree.Path other)
      Specified by:
      compareTo in interface Comparable<Tree.Path>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static Tree.Path of(int... path)
      Create a new path object from the given child indexes.
      Parameters:
      path - the child indexes
      Returns:
      a new tree path
      Throws:
      IllegalArgumentException - if one of the path elements is smaller than zero