Package com.bayesserver
Class TableIterator
- java.lang.Object
-
- com.bayesserver.TableIterator
-
public final class TableIterator extends Object
Allows sequential access to the values in aTable
, using a preferred variable ordering, as opposed to the default sorted order specified inTable.getSortedVariables()
.- See Also:
TableAccessor
,Table
-
-
Constructor Summary
Constructors Constructor Description TableIterator(Table table, Node[] order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the node variables.TableIterator(Table table, Node[] order, Integer[] times)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the node variables.TableIterator(Table table, Variable[] order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables.TableIterator(Table table, Variable[] order, Integer[] times)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables at specified times.TableIterator(Table table, VariableContextCollection order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables.TableIterator(Table table, List<Variable> order, List<Integer> times)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables at specified times.TableIterator(Table table, List<VariableContext> order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the node variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyFrom(double[] values)
Resets the iterator and then copies values from an array into the underlyingTable
using the variable ordering of theTableIterator
, not theTable.getSortedVariables()
.int
getRow()
Gets the current position of the iterator.int
getState(int i)
Gets the state for an individual node indexed by the order of nodes in theTableIterator
.void
getStates(int[] states)
Gets the states of all nodes, based on the order of nodes in theTableIterator
not the underlyingTable
.Table
getTable()
Gets the underlyingTable
.int
getTableRow()
Gets the position of the iterator in the underlyingTable
.double
getValue()
Gets the underlyingTable
value at the current position of the iterator.void
increment()
Moves the iterator to the next value, with respect to theTableIterator
node order.void
reset()
Resets the iterator to the start.void
setValue(double value)
Sets the underlyingTable
value at the current position of the iterator.int
size()
Gets the count of values in the underlyingTable
.
-
-
-
Constructor Detail
-
TableIterator
public TableIterator(Table table, Variable[] order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the variables should be accessed. The last variable's states toggle fastest.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if order does not contain the same variables as [table].
-
TableIterator
public TableIterator(Table table, Variable[] order, Integer[] times)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables at specified times.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the variables should be accessed. The last variable's states toggle fastest.times
- The times for the variables.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if order does not contain the same variables as [table].
-
TableIterator
public TableIterator(Table table, List<Variable> order, List<Integer> times)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables at specified times.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the variables should be accessed. The last variable's states toggle fastest.times
- The times for the variables.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if order does not contain the same variables as [table].
-
TableIterator
public TableIterator(Table table, Node[] order, Integer[] times)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the node variables.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the node variables should be accessed. The last variable's states toggle fastest.times
- The times for the variables.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if the nodes in order do not contain the same variables as [table].
-
TableIterator
public TableIterator(Table table, VariableContextCollection order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the variables. Any times that are contained within theVariableContextCollection
will be used.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the variables should be accessed, including any timing information contained in theVariableContextCollection
. The last variable's states toggle fastest.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if order does not contain the same variables as [table].
-
TableIterator
public TableIterator(Table table, Node[] order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the node variables.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the node variables should be accessed. The last variable's states toggle fastest.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if the nodes in order do not contain the same variables as [table].
-
TableIterator
public TableIterator(Table table, List<VariableContext> order)
Initializes a new instance of theTableIterator
class, allowing sequential access to [table] with a specified [order] for the node variables.- Parameters:
table
- The table whose values are to be accessed.order
- The order in which the node variables should be accessed. The last variable's states toggle fastest.- Throws:
NullPointerException
- Raised if either [table] or [order] is null.IllegalArgumentException
- Raised if the variable-time combinations in order do not match those found in [table].
-
-
Method Detail
-
size
public int size()
Gets the count of values in the underlyingTable
.- Returns:
- The count.
-
getValue
public double getValue()
Gets the underlyingTable
value at the current position of the iterator.- Returns:
- The underlying
Table
value.
-
setValue
public void setValue(double value)
Sets the underlyingTable
value at the current position of the iterator.- Parameters:
value
- The underlyingTable
value.
-
increment
public void increment()
Moves the iterator to the next value, with respect to theTableIterator
node order.
-
getRow
public int getRow()
Gets the current position of the iterator. For the position in the underlyingTable
seegetTableRow()
.- Returns:
- The row.
-
getTableRow
public int getTableRow()
Gets the position of the iterator in the underlyingTable
. For the position of the iterator seegetRow()
.- Returns:
- The table row.
-
copyFrom
public void copyFrom(double[] values)
Resets the iterator and then copies values from an array into the underlyingTable
using the variable ordering of theTableIterator
, not theTable.getSortedVariables()
. At the end of the operation the iterator will be reset to the start.- Parameters:
values
- An array of values to copy.- Throws:
NullPointerException
- Raised if [values] is null.IllegalArgumentException
- Raised if [values] is too short.
-
reset
public void reset()
Resets the iterator to the start.
-
getStates
public void getStates(int[] states)
Gets the states of all nodes, based on the order of nodes in theTableIterator
not the underlyingTable
.- Parameters:
states
- A array, whose values will be replaced. The [states] array must have length equal to or greater than the node count in the underlyingTable
.- Throws:
NullPointerException
- Raised if [states] is null.IllegalArgumentException
- Raised if [states] is too short.
-
getState
public int getState(int i)
Gets the state for an individual node indexed by the order of nodes in theTableIterator
.- Parameters:
i
- The node position, based on the order of nodes in theTableIterator
.- Returns:
- The state.
-
-