maltcms.datastructures.array
Class SparseArray

java.lang.Object
  extended by maltcms.datastructures.array.SparseArray
All Implemented Interfaces:
Serializable, IArrayD2Double

public final class SparseArray
extends Object
implements IArrayD2Double

Author:
Nils.Hoffmann@CeBiTec.Uni-Bielefeld.DE
See Also:
Serialized Form

Constructor Summary
SparseArray(int rows, int columns)
           
 
Method Summary
 int columns()
           
 cross.datastructures.tuple.Tuple2D<ArrayInt.D1,ArrayDouble.D1> flatten()
          Return array in row compressed storage format.
 double get(int row, int col)
           
 ArrayDouble.D2 getArray()
          Use with caution, creates the dense array according to its bounds in memory.
 int[] getColumnBounds(int row)
           
 double getDefaultValue()
           
 int getNumberOfStoredElements()
           
 Area getShape()
           
 boolean inRange(int i, int j)
           
 int rows()
           
 void set(int row, int col, double d)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface maltcms.datastructures.array.IArrayD2Double
toString
 

Constructor Detail

SparseArray

public SparseArray(int rows,
                   int columns)
Method Detail

columns

public int columns()
Specified by:
columns in interface IArrayD2Double
Returns:
the number of columns

flatten

public cross.datastructures.tuple.Tuple2D<ArrayInt.D1,ArrayDouble.D1> flatten()
Description copied from interface: IArrayD2Double
Return array in row compressed storage format.

Specified by:
flatten in interface IArrayD2Double
Returns:
first array int tuple defines offsets of rows in second array

get

public double get(int row,
                  int col)
Specified by:
get in interface IArrayD2Double
Returns:
element if row and col are in valid range, otherwise returns default value

getArray

public ArrayDouble.D2 getArray()
Description copied from interface: IArrayD2Double
Use with caution, creates the dense array according to its bounds in memory.

Specified by:
getArray in interface IArrayD2Double
Returns:
a dense representation of this array

getColumnBounds

public int[] getColumnBounds(int row)
Specified by:
getColumnBounds in interface IArrayD2Double
Returns:
[lowest column in range, length of column]

getDefaultValue

public double getDefaultValue()
Specified by:
getDefaultValue in interface IArrayD2Double
Returns:
the default value, e.g. 0, used for initialization

getNumberOfStoredElements

public int getNumberOfStoredElements()
Specified by:
getNumberOfStoredElements in interface IArrayD2Double
Returns:
the number of elements stored in this array

getShape

public Area getShape()
Specified by:
getShape in interface IArrayD2Double
Returns:
the Area enclosed by this Array

inRange

public boolean inRange(int i,
                       int j)
Specified by:
inRange in interface IArrayD2Double

rows

public int rows()
Specified by:
rows in interface IArrayD2Double
Returns:
the number of rows

set

public void set(int row,
                int col,
                double d)
         throws ArrayIndexOutOfBoundsException
Specified by:
set in interface IArrayD2Double
d - the value to be set at row,col
Throws:
ArrayIndexOutOfBoundsException


Copyright © 2007-2012. All Rights Reserved.