|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsbrt.kernel.math.graph_theory.Path<N>
N
- the node type.public class Path<N>
This class can be used for representing paths in a graph or network. A path is a sequence {x0, x1, ..., xn-1} such that (x0, x1), (x1, x2), ..., (xn-2, xn-1) are edges of a graph, where n is the total number of nodes in the path.
Instances of this class are immutable.
Constructor Summary | |
---|---|
Path(java.util.Collection<? extends N> path)
Constructs a path containing the nodes from the provided collection, in the order they are returned from the collection's iterator. |
|
Path(T[] path)
Constructs a path containing the nodes from the provided array, in the order they occur starting from index 0. |
Method Summary | |
---|---|
boolean |
contains(java.lang.Object node)
Returns true if this path contains the specified node. |
boolean |
equals(java.lang.Object obj)
Compares the specified object with this path for equality. |
N |
get(int index)
Returns the node at the specified position in this path. |
int |
hashCode()
Returns a hash code based on the nodes contained in this path. |
int |
indexOf(java.lang.Object node)
Returns the index in this path of the first occurrence of the specified node, or -1 if this path does not contain that node. |
java.util.Iterator<N> |
iterator()
Returns an iterator over the nodes in this path in proper sequence. |
int |
nodes()
Returns the number of nodes in this path. |
N[] |
toArray()
Returns an array representation of this path. |
java.util.List<N> |
toList()
Returns a list representation of this path. |
java.lang.String |
toString()
Returns a string representation of this path. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Path(T[] path)
T
- a type extending the primary node type.path
- the array whose elements will represent nodes
in this path.
java.lang.NullPointerException
- if the provided array is
null or if a node contained within that array is null
.public Path(java.util.Collection<? extends N> path)
path
- the collection whose elements will represent
nodes in this path.
java.lang.NullPointerException
- if the provided collection
is null
or if a node contained within that
collection is null
.Method Detail |
---|
public int nodes()
public N get(int index)
index
- index of node to return.
java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= nodes()).public int indexOf(java.lang.Object node)
node
- node to search for.
public boolean contains(java.lang.Object node)
node
- node whose presence in this Path is to be
tested.
true
if the specified node is present;
false
otherwise.public java.util.Iterator<N> iterator()
public N[] toArray()
public java.util.List<N> toList()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object with which to compare.
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |