|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.udo.cs.yale.example.FloatSparseArrayDataRow
public class FloatSparseArrayDataRow
Implementation of DataRow that is backed by primitive arrays. Should always be used if more than 50% of the data is sparse. As fast (or even faster than map implementation) but needs considerably less memory. This implementation uses float arrays instead of double arrays which might reduce the used memory even more.
Field Summary | |
---|---|
private int |
counter
Number of inserted elements. |
private float[] |
values
Stores the used attribute values. |
private int[] |
x
Stores the used attribute indices. |
Constructor Summary | |
---|---|
FloatSparseArrayDataRow()
Creates an empty sparse array data row with size 0. |
|
FloatSparseArrayDataRow(int size)
Creates a sparse array data row of the given size. |
Method Summary | |
---|---|
void |
ensureNumberOfColumns(int numberOfColumns)
Does nothing. |
double |
get(Attribute attribute)
Returns the desired data for the given attribute. |
int[] |
getNonDefaultIndices()
Returns an array of all attribute indices with corresponding non-default values. |
double[] |
getNonDefaultValues()
Returns an array of all non-default attribute values. |
private int |
med3(int a,
int b,
int c)
|
void |
set(Attribute attribute,
double v)
Sets the given data for the given attribute. |
private void |
sort(int off,
int len)
Sorts the arrays in the given range. |
private void |
swap(int a,
int b)
Swaps x[a] with x[b]. |
java.lang.String |
toString()
Returns a string representation of the data row. |
void |
trim()
Trims the data row to the number of actually used elements. |
private void |
vecswap(int a,
int b,
int n)
Swaps the next n elements from a and b. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int[] x
private float[] values
private int counter
Constructor Detail |
---|
public FloatSparseArrayDataRow()
public FloatSparseArrayDataRow(int size)
Method Detail |
---|
private void sort(int off, int len)
private void vecswap(int a, int b, int n)
private int med3(int a, int b, int c)
private void swap(int a, int b)
public double get(Attribute attribute)
get
in interface DataRow
public void set(Attribute attribute, double v)
set
in interface DataRow
public int[] getNonDefaultIndices()
SparseDataRow
getNonDefaultIndices
in interface SparseDataRow
public double[] getNonDefaultValues()
SparseDataRow
getNonDefaultValues
in interface SparseDataRow
public void ensureNumberOfColumns(int numberOfColumns)
ensureNumberOfColumns
in interface DataRow
public void trim()
trim
in interface DataRow
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |