dice.data
Class SimpleInstances

java.lang.Object
  extended by dice.data.SimpleInstances
All Implemented Interfaces:
Instances, java.io.Serializable

public class SimpleInstances
extends java.lang.Object
implements Instances

A simple implementation of the interface Instances.

Author:
Zhang Xiatian
See Also:
Serialized Form

Field Summary
protected  int[] attributes
          The array holds the meta information of attributes.
protected  int cursor
          The indicator indicates which record can be get from the instance
protected  int[][] ids
          The index matrix for the data set.
protected  Instance instance
          The object of Instance hold the data for a record, which is determined by cursor.
protected  boolean isSparse
          Indicate the storage form.
protected  java.util.Iterator<Instance> iterator
          An Iterator for Instance
protected  double[][] mat
          The data matrix for the data set.
protected  double miss
          For sparse storage form, it keep the default value for the element ignored.
protected  java.lang.String relation
          The name of the data set.
private static long serialVersionUID
           
protected  Instances thiz
          Keep the reference to this object.
 
Constructor Summary
SimpleInstances(int[] attrs, double[][] matrix, int[][] indexes, java.lang.String relation)
          Create a SimpleInstances.
 
Method Summary
 Instance get(int index)
          Get an instance by the assigned index or position.
 int[] getAttributes()
          Get the arrays, whose elements indicate the types of attributes.
 int getAttrSize()
          Get the number of attributes.
 int[][] getIds()
          Get the index matrix.
 double[][] getMat()
          Get the data matrix.
 java.lang.String getRelation()
          Get the relation name of the data set.
 boolean isSparse()
          Get the storage status of the Instances.
 java.util.Iterator<Instance> iterator()
          Get the iterator.
 void setData(int[][] ids, double[][] mat)
          Put the index and data matrix into it.
 void setMiss(double miss)
          Set the default value for the ignored element in the sparse storage form.
 int size()
          Get the number of Instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

thiz

protected Instances thiz
Keep the reference to this object.


isSparse

protected boolean isSparse
Indicate the storage form. True is sparse, false is dense.


attributes

protected int[] attributes
The array holds the meta information of attributes.

See Also:
Instances.getAttributes()

ids

protected int[][] ids
The index matrix for the data set. Only used for sparse data.

See Also:
Instances.getIds()

mat

protected double[][] mat
The data matrix for the data set.

See Also:
Instances.getMat()

instance

protected Instance instance
The object of Instance hold the data for a record, which is determined by cursor.


cursor

protected int cursor
The indicator indicates which record can be get from the instance


iterator

protected java.util.Iterator<Instance> iterator
An Iterator for Instance


relation

protected java.lang.String relation
The name of the data set.


miss

protected double miss
For sparse storage form, it keep the default value for the element ignored.

Constructor Detail

SimpleInstances

public SimpleInstances(int[] attrs,
                       double[][] matrix,
                       int[][] indexes,
                       java.lang.String relation)
Create a SimpleInstances.

Parameters:
attrs - The attribute type array, @see attributes
matrix - The data matrix, @see mat
indexes - The index matrix, @see ids
relation - The name of the data set, @see relation
Method Detail

iterator

public java.util.Iterator<Instance> iterator()
Get the iterator.

Specified by:
iterator in interface Instances
Returns:
The iteraotr of Instance.

getAttributes

public int[] getAttributes()
Description copied from interface: Instances
Get the arrays, whose elements indicate the types of attributes. 0 indicates the attribute is numeric or real attribute. The number is greater than 0 indicate the numbers of values of each attributes.

Specified by:
getAttributes in interface Instances
Returns:
The attribute type indicator array.
See Also:
Instances.getAttributes()

getRelation

public java.lang.String getRelation()
Description copied from interface: Instances
Get the relation name of the data set.

Specified by:
getRelation in interface Instances
Returns:
The relation name of the data set.
See Also:
Instances.getRelation()

getAttrSize

public int getAttrSize()
Description copied from interface: Instances
Get the number of attributes.

Specified by:
getAttrSize in interface Instances
Returns:
The number of attributes.
See Also:
Instances.getAttrSize()

size

public int size()
Description copied from interface: Instances
Get the number of Instances.

Specified by:
size in interface Instances
Returns:
The number of Instances.
See Also:
Instances.size()

get

public Instance get(int index)
Description copied from interface: Instances
Get an instance by the assigned index or position.

Specified by:
get in interface Instances
Parameters:
index - The index or position of the Instance wanted.
Returns:
The instance wanted.

isSparse

public boolean isSparse()
Description copied from interface: Instances
Get the storage status of the Instances.

Specified by:
isSparse in interface Instances
Returns:
If the data storage form is sparse, then return true. Otherwise, return false.

getIds

public int[][] getIds()
Description copied from interface: Instances
Get the index matrix.

Specified by:
getIds in interface Instances
Returns:
The index matrix. If the Instances.isSparse() return false, the return will be null.

getMat

public double[][] getMat()
Description copied from interface: Instances
Get the data matrix.

Specified by:
getMat in interface Instances
Returns:
The data matrix.

setMiss

public void setMiss(double miss)
Description copied from interface: Instances
Set the default value for the ignored element in the sparse storage form.

Specified by:
setMiss in interface Instances

setData

public void setData(int[][] ids,
                    double[][] mat)
Description copied from interface: Instances
Put the index and data matrix into it.

Specified by:
setData in interface Instances
Parameters:
ids - The index matrix.
mat - The data matrix.
See Also:
Instances.setData(int[][], double[][])