Package io.jenetics.ext.util
Class Tree.Path
- java.lang.Object
-
- io.jenetics.ext.util.Tree.Path
-
- All Implemented Interfaces:
Serializable
public static final class Tree.Path extends Object implements Serializable
This class represents the path to child within a given tree. It allows to point (and fetch) a tree child.- Since:
- 4.4
- Version:
- 6.0
- See Also:
Tree.childAtPath(Path)
, Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tree.Path
append(Tree.Path path)
Appends the givenpath
tothis
one.boolean
equals(Object obj)
int
get(int index)
Return the child index at the given index (child level).int
hashCode()
int
length()
Return the path length, which is the level of the childthis
path points to.static Tree.Path
of(int... path)
Create a new path object from the given child indexes.int[]
toArray()
Return the path asint[]
array.String
toString()
-
-
-
Method Detail
-
length
public int length()
Return the path length, which is the level of the childthis
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 asint[]
array.- Returns:
- the path as
int[]
array
-
append
public Tree.Path append(Tree.Path path)
Appends the givenpath
tothis
one.- Parameters:
path
- the path to append- Returns:
- a new
Path
with the givenpath
appended - Throws:
NullPointerException
- if the givenpath
isnull
-
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
-
-