edu.ucla.belief
Class TableIndex

Object
  extended by TableIndex
All Implemented Interfaces:
Cloneable

public class TableIndex
extends Object
implements Cloneable

A class for mapping from variable instantiations to a linear index.

Author:
jpark, Keith Cascio

Nested Class Summary
 class TableIndex.Iterator
          A class for stepping through the instantiations of an index.
 
Constructor Summary
TableIndex(Collection variables)
          creates an index over the variables supplied.
TableIndex(Object[] variables)
          creates an index over the variables.
TableIndex(TableIndex toCopy)
           
 
Method Summary
 int blockSize(FiniteVariable var)
          Returns the change in index of incrementing the value of the dimension corresponding to var by 1 while holding all others constant.
 int blockSize(int i)
          Returns the change in index of incrementing the value of the ith dimension by 1 while holding all others constant.
 int cardinality(int index)
           
 Object clone()
           
 boolean equals(Object obj)
           
 int[] fill(Map mapInstantiations, int[] mind)
           
 TableIndex forget(Set variables)
          Returns a new index formed by removing any dimensions whose associated with the variables contained in variables.
 int[] getDimensionIndices(Object[] variables)
          Returns the dimensions that correspond to the given variables.
 int[] getDimensionIndices(TableIndex ind)
          returns the dimensions that correspond to the variables in ind.
 FiniteVariable getJoint()
          Returns the child variable.
 int getNumVariables()
           
 FiniteVariable[] getParents()
          Returns an array containing the variable associated with each dimension.
 HashSet getParentsSet()
           
 int hashCode()
           
 int index(int[] mind)
          Converts the multidimensional index to the corresponding linear index.
 int index(Map mapInstantiations)
           
 int index(Object[] instantiations)
           
 int[] intoMapping(TableIndex ind2)
          Returns an array where result[i] is the entry in this index that is compatible with the ith entry in ind2.
 TableIndex.Iterator iterator()
          returns an iterator over the indices in the array.
 int[] mindex(int index, int[] mind)
          Converts the linear index to the corresponding multidimensional index.
 TableIndex multiply(TableIndex ind2)
          Returns the Index which corresponds to basically the cartesian product of the two arrays.
 TableIndex project(Set variables)
          Returns a new index formed from limiting the current index to the variables contained in variables.
 int[] shrinkMapping(TableIndex ind2, Map inst)
          Returns an array where result[i] is the entry in ind2 that is compatible with the ith entry of this index and is compatible with inst.
 int size()
          returns the total number of elements that the index represents.
 FiniteVariable variable(int dim)
          returns the variable index of the specified dimesion.
 int variableIndex(FiniteVariable fv)
          Returns the position of the variable in the array.
 List variables()
           
 
Methods inherited from class Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableIndex

public TableIndex(TableIndex toCopy)

TableIndex

public TableIndex(Collection variables)
creates an index over the variables supplied. The ordering will be the order the iterator returns the variables.


TableIndex

public TableIndex(Object[] variables)
creates an index over the variables. The first variable is most significant in the resulting index.

Method Detail

clone

public Object clone()
Overrides:
clone in class Object

cardinality

public int cardinality(int index)
Since:
101402

variables

public List variables()
Since:
041602

variableIndex

public int variableIndex(FiniteVariable fv)
Returns the position of the variable in the array.


blockSize

public int blockSize(int i)
Returns the change in index of incrementing the value of the ith dimension by 1 while holding all others constant.


blockSize

public int blockSize(FiniteVariable var)
Returns the change in index of incrementing the value of the dimension corresponding to var by 1 while holding all others constant.


getNumVariables

public int getNumVariables()
Since:
100702

size

public int size()
returns the total number of elements that the index represents.


index

public int index(int[] mind)
Converts the multidimensional index to the corresponding linear index.


fill

public int[] fill(Map mapInstantiations,
                  int[] mind)
Since:
021704

index

public int index(Map mapInstantiations)
Since:
021704

index

public int index(Object[] instantiations)
Since:
100702

mindex

public int[] mindex(int index,
                    int[] mind)
Converts the linear index to the corresponding multidimensional index. If mind!=null, the mind is set to contain the result.


iterator

public TableIndex.Iterator iterator()
returns an iterator over the indices in the array.


variable

public FiniteVariable variable(int dim)
returns the variable index of the specified dimesion.


getJoint

public FiniteVariable getJoint()
Returns the child variable.

Since:
101502

getDimensionIndices

public int[] getDimensionIndices(Object[] variables)
Returns the dimensions that correspond to the given variables.


getDimensionIndices

public int[] getDimensionIndices(TableIndex ind)
returns the dimensions that correspond to the variables in ind.


equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getParents

public FiniteVariable[] getParents()
Returns an array containing the variable associated with each dimension.


getParentsSet

public HashSet getParentsSet()

multiply

public TableIndex multiply(TableIndex ind2)
Returns the Index which corresponds to basically the cartesian product of the two arrays.


project

public TableIndex project(Set variables)
Returns a new index formed from limiting the current index to the variables contained in variables. note: variables need not be restricted to those in the current index, but the result will only contain variables in the intersection.


forget

public TableIndex forget(Set variables)
Returns a new index formed by removing any dimensions whose associated with the variables contained in variables.


intoMapping

public int[] intoMapping(TableIndex ind2)
Returns an array where result[i] is the entry in this index that is compatible with the ith entry in ind2.


shrinkMapping

public int[] shrinkMapping(TableIndex ind2,
                           Map inst)
Returns an array where result[i] is the entry in ind2 that is compatible with the ith entry of this index and is compatible with inst.

Parameters:
ind2 - The TableIndex to shrink from
inst - The mapping from variable to value for some subset of the variables in ind2 that aren't in this.


Copyright 2010 UCLA Automated Reasoning Group