infovis.column
Class IntSparseColumn

java.lang.Object
  extended by infovis.utils.ChangeManager
      extended by infovis.column.AbstractColumn
          extended by infovis.column.BasicColumn
              extended by infovis.column.IntSparseColumn
All Implemented Interfaces:
IntComparator, Column, NumberColumn, Metadata, Constants, RowComparator, Serializable

public class IntSparseColumn
extends BasicColumn
implements NumberColumn

Class IntSparseColumn

Version:
$Revision: 1.9 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form
InfoVis factory arguments:
ColumnFactory "integer" SPARSE

Field Summary
 
Fields inherited from class infovis.column.AbstractColumn
MODIFIED_ALL, MODIFIED_NONE
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Constructor Summary
IntSparseColumn(String name)
           
 
Method Summary
 void add(int element)
          Adds a new element in the column,
 int capacity()
          Returns the current capacity of this column.
 void clear()
          Removes all of the elements from this column.
 int compare(int row1, int row2)
          
 boolean compareValues(Column c)
          Compare the values of this column and the specified column.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this column, if necessary, to ensure that it can hold at least the number of values specified by the minimum capacity argument.
static IntSparseColumn findColumn(Table t, String name)
          Returns a column as a IntColumn from a table, creating it if needed.
 String format(double value)
          Returns the specified value formatted according to this column's format.
 String format(int v)
          Returns the string representation of a value according to the current format.
 int get(int index)
           
static IntSparseColumn getColumn(Table t, int index)
          Returns a column as a IntColumn from an Table.
static IntSparseColumn getColumn(Table t, String name)
          Returns a column as an IntColumn from a Table.
 double getDoubleAt(int row)
          Returns the value as a double.
 double getDoubleMax()
          Returns the largset value as a double.
 double getDoubleMin()
          Returns the smallest value as a double.
 float getFloatAt(int row)
          Returns the value as a float.
 int getIntAt(int row)
          Returns the value as an int.
 long getLongAt(int row)
          Returns the value as a long.
 int getMax()
           
 int getMin()
           
 String getValueAt(int i)
          Returns the String representation of the element at the specified position in this column or null if the element is undefined.
 Class getValueClass()
          Returns the class of the elements.
 IntIntSortedMap getValueReference()
           
 boolean hasUndefinedValue()
          Returns true if the columns contains undefined values, false otherwise.
 boolean isValueUndefined(int i)
          Returns true if the ith value is undefined.
 RowIterator iterator()
          Returns a RowIterator over all the valid rows of this column.
 int parse(String v)
          Parse a string and return the value for the column.
 double round(double value)
          Returns the rounded value according to the semantics of this number value.
 void set(int index, int element)
           
 void setDoubleAt(int row, double v)
          Sets the value as a double.
 void setExtend(int index, int element)
           
 void setFloatAt(int row, float v)
          Sets the value as a float.
 void setIntAt(int row, int v)
          Sets the value as an int.
 void setLongAt(int row, long v)
          Sets the value as a long.
 void setSize(int newSize)
          Sets the sizeColumn of this column.
 void setValueAt(int i, String v)
          Replaces the element at the specified position in this column with the element specified in its String representation or sets if undefined if the element is null It will be read and translated using the Format.
 void setValueUndefined(int i, boolean undef)
          Sets the ith element to have an undefined value.
 int size()
          Returns the number of elements in this column.
 int[] toArray()
          Returns the array of integer values used by the column.
 int[] toArray(int[] a)
          Returns the array of integer values copied from the column.
 
Methods inherited from class infovis.column.BasicColumn
addValue, addValueOrNull, firstValidRow, getClientProperty, getFormat, getMaxIndex, getMetadata, getMinIndex, getName, isEmpty, isInternal, lastValidRow, setFormat, setName, setValueOrNullAt, toString
 
Methods inherited from class infovis.column.AbstractColumn
addChangeListener, computeValueMap, computeValueMap, equalObj, equals, getLastModifiedRow
 
Methods inherited from class infovis.utils.ChangeManager
disableNotify, enableNotify, getModCount, removeChangeListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface infovis.Column
addChangeListener, addValue, addValueOrNull, disableNotify, enableNotify, getFormat, getMaxIndex, getMinIndex, getName, isEmpty, isInternal, removeChangeListener, setFormat, setName, setValueOrNullAt
 
Methods inherited from interface infovis.Metadata
getClientProperty, getMetadata
 
Methods inherited from interface cern.colt.function.IntComparator
equals
 

Constructor Detail

IntSparseColumn

public IntSparseColumn(String name)
Method Detail

setSize

public void setSize(int newSize)
Description copied from class: BasicColumn
Sets the sizeColumn of this column. If the new sizeColumn is greater than the current sizeColumn, new 0 items are added to the end of the column. If the new sizeColumn is less than the current sizeColumn, all components at index newSize and greater are discarded.

Specified by:
setSize in interface Column
Specified by:
setSize in class BasicColumn
Parameters:
newSize - the new sizeColumn of this column.

isValueUndefined

public boolean isValueUndefined(int i)
Description copied from interface: Column
Returns true if the ith value is undefined.

Specified by:
isValueUndefined in interface Column
Specified by:
isValueUndefined in interface RowComparator
Parameters:
i - the index
Returns:
true if the ith value is undefined.

setValueUndefined

public void setValueUndefined(int i,
                              boolean undef)
Description copied from interface: Column
Sets the ith element to have an undefined value.

Specified by:
setValueUndefined in interface Column
Parameters:
i - the index
undef - true if the value should be undefined, false otherwise.

size

public int size()
Description copied from interface: Column
Returns the number of elements in this column.

Specified by:
size in interface Column
Returns:
the number of elements in this column.

hasUndefinedValue

public boolean hasUndefinedValue()
Description copied from interface: Column
Returns true if the columns contains undefined values, false otherwise.

Specified by:
hasUndefinedValue in interface Column
Returns:
true if the columns contains undefined values, false otherwise.

clear

public void clear()
Description copied from class: BasicColumn
Removes all of the elements from this column. The Column will be empty after this call returns. WARNING: if there is an associated format that maintains a status, such as a CategoricalFormat, it is not cleared so results may not be what you expected. The CategoricalFormat can be cleared explicitely if needed.

Specified by:
clear in interface Column
Overrides:
clear in class BasicColumn

compareValues

public boolean compareValues(Column c)
Description copied from class: AbstractColumn
Compare the values of this column and the specified column.

Overrides:
compareValues in class AbstractColumn
Parameters:
c - the column to compare values from
Returns:
true if the values match, false otherwise

capacity

public int capacity()
Description copied from interface: Column
Returns the current capacity of this column.

Specified by:
capacity in interface Column
Returns:
the current capacity .

get

public int get(int index)

set

public void set(int index,
                int element)

setExtend

public void setExtend(int index,
                      int element)

add

public void add(int element)
Adds a new element in the column,

Parameters:
element - the element.

parse

public int parse(String v)
          throws ParseException
Parse a string and return the value for the column.

Parameters:
v - the string representation of the value
Returns:
the value
Throws:
ParseException - if the value cannot be parsed

format

public String format(int v)
Returns the string representation of a value according to the current format.

Parameters:
v - the value
Returns:
the string representation.

getColumn

public static IntSparseColumn getColumn(Table t,
                                        int index)
Returns a column as a IntColumn from an Table.

Parameters:
t - the Table
index - index in the Table
Returns:
a IntColumn or null if no such column exists or the column is not a IntColumn.

getColumn

public static IntSparseColumn getColumn(Table t,
                                        String name)
Returns a column as an IntColumn from a Table.

Parameters:
t - the Table
name - the column name.
Returns:
a IntColumn or null if no such column exists or the column is not a IntColumn.

findColumn

public static IntSparseColumn findColumn(Table t,
                                         String name)
Returns a column as a IntColumn from a table, creating it if needed.

Parameters:
t - the Table
name - the column name.
Returns:
a column as a IntColumn from a table,

getValueClass

public Class getValueClass()
Description copied from class: BasicColumn
Returns the class of the elements.

Specified by:
getValueClass in interface Column
Specified by:
getValueClass in class BasicColumn
Returns:
the class of the elements.
See Also:
Column.getValueClass()

getDoubleAt

public double getDoubleAt(int row)
Description copied from interface: NumberColumn
Returns the value as a double.

Specified by:
getDoubleAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as a double
See Also:
NumberColumn.getDoubleAt(int)

getFloatAt

public float getFloatAt(int row)
Description copied from interface: NumberColumn
Returns the value as a float.

Specified by:
getFloatAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as a float
See Also:
NumberColumn.getFloatAt(int)

getIntAt

public int getIntAt(int row)
Description copied from interface: NumberColumn
Returns the value as an int.

Specified by:
getIntAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as an int
See Also:
NumberColumn.getIntAt(int)

getLongAt

public long getLongAt(int row)
Description copied from interface: NumberColumn
Returns the value as a long.

Specified by:
getLongAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as a long
See Also:
NumberColumn.getLongAt(int)

setDoubleAt

public void setDoubleAt(int row,
                        double v)
Description copied from interface: NumberColumn
Sets the value as a double.

Specified by:
setDoubleAt in interface NumberColumn
Parameters:
row - the row
v - the value as a double
See Also:
NumberColumn.setDoubleAt(int, double)

setIntAt

public void setIntAt(int row,
                     int v)
Description copied from interface: NumberColumn
Sets the value as an int.

Specified by:
setIntAt in interface NumberColumn
Parameters:
row - the row
v - the value as an int
See Also:
NumberColumn.setIntAt(int, int)

setLongAt

public void setLongAt(int row,
                      long v)
Description copied from interface: NumberColumn
Sets the value as a long.

Specified by:
setLongAt in interface NumberColumn
Parameters:
row - the row
v - the value as a long
See Also:
NumberColumn.setLongAt(int, long)

round

public double round(double value)
Description copied from interface: NumberColumn
Returns the rounded value according to the semantics of this number value.

Specified by:
round in interface NumberColumn
Parameters:
value - the value to round
Returns:
the rounded value according to the semantics of this number value.
See Also:
NumberColumn.round(double)

format

public String format(double value)
Description copied from interface: NumberColumn
Returns the specified value formatted according to this column's format.

Specified by:
format in interface NumberColumn
Parameters:
value - the value to format
Returns:
the string formatted according to this column's format.

ensureCapacity

public void ensureCapacity(int minCapacity)
Description copied from interface: Column
Increases the capacity of this column, if necessary, to ensure that it can hold at least the number of values specified by the minimum capacity argument.

Specified by:
ensureCapacity in interface Column
Parameters:
minCapacity - the desired minimum capacity.

getValueAt

public String getValueAt(int i)
Description copied from interface: Column
Returns the String representation of the element at the specified position in this column or null if the element is undefined. The representation is generated by the current format.

Specified by:
getValueAt in interface Column
Parameters:
i - index of element representation to return.
Returns:
the String representation of element at the specified position in this column or null if the element is undefined.
See Also:
Column.getValueAt(int)

setValueAt

public void setValueAt(int i,
                       String v)
                throws ParseException
Description copied from interface: Column
Replaces the element at the specified position in this column with the element specified in its String representation or sets if undefined if the element is null It will be read and translated using the Format. A null value sets the value to undefined. The column is extended if needed.

Specified by:
setValueAt in interface Column
Parameters:
i - index of element to replace.
v - element to be stored at the specified position.
Throws:
ParseException - if the specified string cannot be parsed.
See Also:
Column.setValueAt(int, String)

getValueReference

public IntIntSortedMap getValueReference()

setFloatAt

public void setFloatAt(int row,
                       float v)
Description copied from interface: NumberColumn
Sets the value as a float.

Specified by:
setFloatAt in interface NumberColumn
Parameters:
row - the row
v - the value as a float

getMin

public int getMin()

getMax

public int getMax()

getDoubleMin

public double getDoubleMin()
Description copied from interface: NumberColumn
Returns the smallest value as a double.

Specified by:
getDoubleMin in interface NumberColumn
Returns:
the smallest value as a double.

getDoubleMax

public double getDoubleMax()
Description copied from interface: NumberColumn
Returns the largset value as a double.

Specified by:
getDoubleMax in interface NumberColumn
Returns:
the largset value as a double.

toArray

public int[] toArray(int[] a)
Returns the array of integer values copied from the column.

Parameters:
a - an array of int with at least the column size or null.
Returns:
the array of integer values copied from the column.

toArray

public int[] toArray()
Returns the array of integer values used by the column. BEWARE! no copy is done for performance reasons and the array should only be read. It may become out of sync with the column if the column is resized.

Returns:
the array of integer values used by the column.

iterator

public RowIterator iterator()
Description copied from class: BasicColumn
Returns a RowIterator over all the valid rows of this column.

Specified by:
iterator in interface Column
Overrides:
iterator in class BasicColumn
Returns:
a RowIterator over all the valid rows of this column.

compare

public int compare(int row1,
                   int row2)
Description copied from class: BasicColumn

Specified by:
compare in interface IntComparator
Overrides:
compare in class BasicColumn
See Also:
IntComparator.compare(int,int)


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.