maltcms.datastructures.array
Class DenseArray

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

public class DenseArray
extends Object
implements IArrayD2Double

A simple dense array encapsulation class.

Author:
Nils.Hoffmann@cebitec.uni-bielefeld.de
See Also:
Serialized Form

Constructor Summary
DenseArray(Array a)
          Copy a and save it in internal array
DenseArray(int rows, int columns, double defaultValue1)
          Create new Array with specified number of rows and columns.
 
Method Summary
 int columns()
           
static BufferedImage createLayoutImage(DenseArray pa, Color bg, Color fg)
           
 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

DenseArray

public DenseArray(Array a)
Copy a and save it in internal array

Parameters:
a -

DenseArray

public DenseArray(int rows,
                  int columns,
                  double defaultValue1)
Create new Array with specified number of rows and columns. Initialize with defaultValue1.

Parameters:
rows -
columns -
defaultValue1 -
Method Detail

createLayoutImage

public static BufferedImage createLayoutImage(DenseArray pa,
                                              Color bg,
                                              Color fg)

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.