public class HapNodes
extends java.lang.Object
Class HapNodes
stores nodes and associated values.
Instances of class HapNodes
are not thread safe.
Constructor and Description |
---|
HapNodes()
Creates a new instance of
HapNodes that has an
initial value of 0 for each node. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Sets the value of each node to 0.
|
int |
enumNode(int index)
Returns the specified node in a list of nodes with non-zero value.
|
float |
enumValue(int index)
Returns the value of the specified node in a list of nodes with
non-zero value.
|
int |
size()
Returns the number of nodes with non-zero value.
|
void |
sumUpdate(int node,
float value)
Adds the specified value to the stored value of the specified
node.
|
java.lang.String |
toString()
Returns a string representation of
this . |
float |
value(int node)
Returns the specified node value.
|
public HapNodes()
HapNodes
that has an
initial value of 0 for each node.public void sumUpdate(int node, float value)
node
- the nodevalue
- the valuejava.lang.IllegalArgumentException
- if node < 0
java.lang.IllegalArgumentException
- if
value <= 0 || (Double.isFinite(value) == false)
public int size()
public int enumNode(int index)
(index >= 0 && index < this.size())
, then the
following expression will always evaluate to true
:(this.value(this.enumNode(index)) == this.enumValue(index))
.index
- an index in a list of nodes with non-zero valuejava.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.size()
public float enumValue(int index)
(index >= 0 && index < this.size())
, then
the following expression will always evaluate to true
:(this.value(this.enumNode(index)) == this.enumValue(index))
.index
- an index in a list of nodes with non-zero valuejava.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.size()
public float value(int node)
node
- the first nodejava.lang.IllegalArgumentException
- if node < 0
public void clear()
public java.lang.String toString()
this
. The exact
details of the representation are unspecified and subject to change.toString
in class java.lang.Object
this