Package com.bayesserver
Class TableAccessor
- java.lang.Object
-
- com.bayesserver.TableAccessor
-
public final class TableAccessor extends Object
Allows random access to the values in aTable, using a preferred variable ordering, as opposed to the default sorted order specified inTable.getSortedVariables().- See Also:
TableIterator,Table
-
-
Constructor Summary
Constructors Constructor Description TableAccessor(Table table, Node[] order)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the node variables.TableAccessor(Table table, Node[] order, Integer[] times)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the node variables.TableAccessor(Table table, Variable[] order)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the variables.TableAccessor(Table table, Variable[] order, Integer[] times)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the variables at specified times.TableAccessor(Table table, VariableContextCollection order)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the variables.TableAccessor(Table table, List<Variable> order, List<Integer> times)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the variables at specified times.TableAccessor(Table table, List<VariableContext> order)Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyFrom(double[] values)Copies values from an array into the underlyingTableusing the variable ordering of theTableAccessor, not theTable.getSortedVariables().doubleget(int i)Gets the underlyingTablevalue, specified i.doubleget(int[] states)Gets the underlyingTablevalue, using states corresponding to the order of variables in theTableAccessor.intgetRow(int[] states)Gets theTableAccessorrow for the given states.intgetState(int i, int node)Gets the state at the given position [i] for the node given by [node].voidgetStates(int i, int[] states)Gets the states at the given position [i].TablegetTable()Gets the underlyingTable.intgetTableIndex(int i)Gets the equivalent index in the underlying table that corresponds to the index in the accessor.voidset(int[] states, double value)Sets the underlyingTablevalue, using states corresponding to the order of variables in theTableAccessor.voidset(int i, double value)Sets the underlyingTablevalue, specified i.intsize()Gets the count of values in the underlyingTable.
-
-
-
Constructor Detail
-
TableAccessor
public TableAccessor(Table table, Variable[] order)
Initializes a new instance of theTableAccessorclass, allowing random 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].- See Also:
TableIterator
-
TableAccessor
public TableAccessor(Table table, List<VariableContext> order)
Initializes a new instance of theTableAccessorclass, allowing random 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, defined using variable contexts. 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].- See Also:
TableIterator
-
TableAccessor
public TableAccessor(Table table, VariableContextCollection order)
Initializes a new instance of theTableAccessorclass, allowing random access to [table] with a specified [order] for the variables. Any times that are contained within theVariableContextCollectionwill 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].
-
TableAccessor
public TableAccessor(Table table, Node[] order, Integer[] times)
Initializes a new instance of theTableAccessorclass, allowing random 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 node 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].
-
TableAccessor
public TableAccessor(Table table, Variable[] order, Integer[] times)
Initializes a new instance of theTableAccessorclass, allowing random 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].
-
TableAccessor
public TableAccessor(Table table, List<Variable> order, List<Integer> times)
Initializes a new instance of theTableAccessorclass, allowing random 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].
-
TableAccessor
public TableAccessor(Table table, Node[] order)
Initializes a new instance of theTableAccessorclass, allowing random 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].- See Also:
TableIterator
-
-
Method Detail
-
copyFrom
public void copyFrom(double[] values)
Copies values from an array into the underlyingTableusing the variable ordering of theTableAccessor, not theTable.getSortedVariables().- Parameters:
values- An array of values to copy.- Throws:
NullPointerException- Raised if [values] is null.IllegalArgumentException- Raised if [values] is too short.
-
size
public int size()
Gets the count of values in the underlyingTable.- Returns:
- The count.
-
get
public double get(int[] states)
Gets the underlyingTablevalue, using states corresponding to the order of variables in theTableAccessor.- Returns:
- The underlying
Tablevalue.
-
set
public void set(int[] states, double value)Sets the underlyingTablevalue, using states corresponding to the order of variables in theTableAccessor.- Parameters:
value- The underlyingTablevalue.
-
get
public double get(int i)
Gets the underlyingTablevalue, specified i.- Returns:
- The table value.
-
set
public void set(int i, double value)Sets the underlyingTablevalue, specified i.- Parameters:
value- The table value.
-
getStates
public void getStates(int i, int[] states)Gets the states at the given position [i]. The position is relative to specified variable ordering in theTableAccessor.- Parameters:
i- The position at which to retrieve the states.states- A buffer for the states, which is overwritten by the method.- Throws:
NullPointerException- Raised if [states] is null.IllegalArgumentException- Raised if [states] is too short.
-
getRow
public int getRow(int[] states)
Gets theTableAccessorrow for the given states. The row is relative to the specified variable ordering in theTableAccessor.- Parameters:
states- The states.- Returns:
- The corresponding row in the
TableAccessor. - Throws:
NullPointerException- [states] is null.IllegalArgumentException- [states] length does not equal the number of variables in theTableAccessor.
-
getState
public int getState(int i, int node)Gets the state at the given position [i] for the node given by [node]. The position is relative to the specified variable ordering in theTableAccessor.- Parameters:
i- The position at which to retrieve the state.node- The node.- Returns:
- The state.
-
getTableIndex
public int getTableIndex(int i)
Gets the equivalent index in the underlying table that corresponds to the index in the accessor.- Parameters:
i- The accessor index.- Returns:
- The equivalent underlying table index.
-
-