Source Code (Use browser search to find items of interest.)

Class Index

kblackbox'RectOnArray (./kdegames/kblackbox/util.h:21)

class RectOnArray
{
public:
  RectOnArray( int w, int h );
  ~RectOnArray();

  int get( int col, int row );
  void set( int col, int row, ArrayType type );
  void fill( ArrayType type );

  int width();
  int height();

private:
  int indexOf( int col, int row ) const;

  int w;
  int h;
  ArrayType *array;
};

kblackbox'RectOnArray::RectOnArray() (./kdegames/kblackbox/util.cpp:14)

RectOnArray::RectOnArray( int w, int h ) 
{
  array = new ArrayType[w*h];
  this->w = w;
  this->h = h;
}


kblackbox'RectOnArray::~RectOnArray() (./kdegames/kblackbox/util.cpp:21)

RectOnArray::~RectOnArray() 
{
  delete[] array;
}

/*
   Size info...
*/


kblackbox'RectOnArray::width() (./kdegames/kblackbox/util.cpp:30)

int RectOnArray::width() { return w; }

kblackbox'RectOnArray::height() (./kdegames/kblackbox/util.cpp:31)

int RectOnArray::height() { return h; }

/*
   Utility function for mapping from 2D table to 1D array
*/


kblackbox'RectOnArray::indexOf() (./kdegames/kblackbox/util.cpp:37)

int RectOnArray::indexOf( int col, int row ) const
{
    return (row * w) + col;
}

/*
   Return content of cell
*/


kblackbox'RectOnArray::get() (./kdegames/kblackbox/util.cpp:46)

ArrayType RectOnArray::get( int col, int row )
{
  return array[indexOf( col, row )];
}

/*
   Set content of cell
*/


kblackbox'RectOnArray::set() (./kdegames/kblackbox/util.cpp:55)

void RectOnArray::set( int col, int row, ArrayType type )
{
  array[indexOf( col, row )] = type;
}

/*
   Fill all cells witj type
*/


kblackbox'RectOnArray::fill() (./kdegames/kblackbox/util.cpp:64)

void RectOnArray::fill( ArrayType type )
{
  int i;
  for (i = 0; i < w*h; i++) array[i] = type;
}