KGrid2D::Generic< Type > Class Template Reference

This template class represents a generic bidimensionnal grid. More...

#include <kgrid2d.h>

Inheritance diagram for KGrid2D::Generic< Type >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Generic (uint width=0, uint height=0)
 Constructor.
virtual ~Generic ()
void resize (uint width, uint height)
 Resize the grid.
void fill (const Type &value)
 Fill the nodes with the given value.
uint width () const
 
Returns:
the width.

uint height () const
 
Returns:
the height.

uint size () const
 
Returns:
the number of nodes (ie width*height).

uint index (const Coord &c) const
 
Returns:
the linear index for the given coordinate.

Coord coord (uint index) const
 
Returns:
the coordinate corresponding to the linear index.

const Type & at (const Coord &c) const
 
Returns:
the value at the given coordinate.

Type & at (const Coord &c)
 
Returns:
the value at the given coordinate.

const Type & operator[] (const Coord &c) const
 
Returns:
the value at the given coordinate.

Type & operator[] (const Coord &c)
 
Returns:
the value at the given coordinate.

const Type & at (uint index) const
 
Returns:
the value at the given linear index.

Type & at (uint index)
 
Returns:
the value at the given linear index.

const Type & operator[] (uint index) const
 
Returns:
the value at the given linear index.

Type & operator[] (uint index)
 
Returns:
the value at the given linear index.

bool inside (const Coord &c) const
 
Returns:
if the given coordinate is inside the grid.

void bound (Coord &c) const
 Bound the given coordinate with the grid dimensions.

Protected Attributes

uint _width
uint _height
QVector< Type > _vector


Detailed Description

template<class Type>
class KGrid2D::Generic< Type >

This template class represents a generic bidimensionnal grid.

Each node contains an element of the template type.

Definition at line 91 of file kgrid2d.h.


Constructor & Destructor Documentation

template<class Type>
KGrid2D::Generic< Type >::Generic ( uint  width = 0,
uint  height = 0 
) [inline]

Constructor.

Definition at line 97 of file kgrid2d.h.

template<class Type>
virtual KGrid2D::Generic< Type >::~Generic (  )  [inline, virtual]

Definition at line 101 of file kgrid2d.h.


Member Function Documentation

template<class Type>
void KGrid2D::Generic< Type >::resize ( uint  width,
uint  height 
) [inline]

Resize the grid.

Definition at line 106 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::Generic(), and operator>>().

template<class Type>
void KGrid2D::Generic< Type >::fill ( const Type &  value  )  [inline]

Fill the nodes with the given value.

Definition at line 115 of file kgrid2d.h.

template<class Type>
uint KGrid2D::Generic< Type >::width (  )  const [inline]

Returns:
the width.

Definition at line 122 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::Generic().

template<class Type>
uint KGrid2D::Generic< Type >::height (  )  const [inline]

Returns:
the height.

Definition at line 126 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::Generic().

template<class Type>
uint KGrid2D::Generic< Type >::size (  )  const [inline]

Returns:
the number of nodes (ie width*height).

Definition at line 130 of file kgrid2d.h.

Referenced by operator>>().

template<class Type>
uint KGrid2D::Generic< Type >::index ( const Coord c  )  const [inline]

Returns:
the linear index for the given coordinate.

Definition at line 135 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::at(), and KGrid2D::Generic< T >::operator[]().

template<class Type>
Coord KGrid2D::Generic< Type >::coord ( uint  index  )  const [inline]

Returns:
the coordinate corresponding to the linear index.

Definition at line 142 of file kgrid2d.h.

template<class Type>
const Type& KGrid2D::Generic< Type >::at ( const Coord c  )  const [inline]

Returns:
the value at the given coordinate.

Definition at line 149 of file kgrid2d.h.

template<class Type>
Type& KGrid2D::Generic< Type >::at ( const Coord c  )  [inline]

Returns:
the value at the given coordinate.

Definition at line 153 of file kgrid2d.h.

template<class Type>
const Type& KGrid2D::Generic< Type >::operator[] ( const Coord c  )  const [inline]

Returns:
the value at the given coordinate.

Definition at line 157 of file kgrid2d.h.

template<class Type>
Type& KGrid2D::Generic< Type >::operator[] ( const Coord c  )  [inline]

Returns:
the value at the given coordinate.

Definition at line 161 of file kgrid2d.h.

template<class Type>
const Type& KGrid2D::Generic< Type >::at ( uint  index  )  const [inline]

Returns:
the value at the given linear index.

Definition at line 166 of file kgrid2d.h.

template<class Type>
Type& KGrid2D::Generic< Type >::at ( uint  index  )  [inline]

Returns:
the value at the given linear index.

Definition at line 170 of file kgrid2d.h.

template<class Type>
const Type& KGrid2D::Generic< Type >::operator[] ( uint  index  )  const [inline]

Returns:
the value at the given linear index.

Definition at line 174 of file kgrid2d.h.

template<class Type>
Type& KGrid2D::Generic< Type >::operator[] ( uint  index  )  [inline]

Returns:
the value at the given linear index.

Definition at line 178 of file kgrid2d.h.

template<class Type>
bool KGrid2D::Generic< Type >::inside ( const Coord c  )  const [inline]

Returns:
if the given coordinate is inside the grid.

Definition at line 183 of file kgrid2d.h.

template<class Type>
void KGrid2D::Generic< Type >::bound ( Coord c  )  const [inline]

Bound the given coordinate with the grid dimensions.

Definition at line 191 of file kgrid2d.h.


Member Data Documentation

template<class Type>
uint KGrid2D::Generic< Type >::_width [protected]

Definition at line 197 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::bound(), KGrid2D::Generic< T >::coord(), KGrid2D::Generic< T >::index(), KGrid2D::Generic< T >::inside(), KGrid2D::Generic< T >::resize(), KGrid2D::Generic< T >::size(), and KGrid2D::Generic< T >::width().

template<class Type>
uint KGrid2D::Generic< Type >::_height [protected]

Definition at line 197 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::bound(), KGrid2D::Generic< T >::height(), KGrid2D::Generic< T >::inside(), KGrid2D::Generic< T >::resize(), and KGrid2D::Generic< T >::size().

template<class Type>
QVector<Type> KGrid2D::Generic< Type >::_vector [protected]

Definition at line 198 of file kgrid2d.h.

Referenced by KGrid2D::Generic< T >::at(), KGrid2D::Generic< T >::fill(), KGrid2D::Generic< T >::operator[](), and KGrid2D::Generic< T >::resize().


The documentation for this class was generated from the following file:
Generated on Sun Mar 16 08:03:27 2008 for Libkdegames by  doxygen 1.5.3