Walls And Holes  1
Array2D< Type > Class Template Reference

The Array2D class is basically a 2D implementation of QVector. More...

#include <array2d.h>

Public Types

using IndexCollection = Array2D_Private::Array2DPointWrapper
 
using IndexedConstDataCollection = Array2D_Private::Array2DPointAndConstDataWrapper< Type >
 

Public Member Functions

 Array2D ()
 
 Array2D (int rows, int cols, Type defaultValue)
 
 Array2D (int rows, int cols)
 
 Array2D (QSize size)
 
const Type & operator() (int r, int c) const
 
Type & operator() (int r, int c)
 
const Type & operator() (QPoint p) const
 
Type & operator() (QPoint p)
 
void resize (int rows, int cols)
 
QSize size () const
 
int width () const
 
int height () const
 
bool isInBounds (QPoint p) const
 Returns true if (p.x(), p.y()) is a valid region. More...
 
IndexCollection indices () const
 indices Returns a lightweight object for iterating over all valid (x,y) pairs. More...
 
IndexedConstDataCollection indexedData () const
 indexedData Returns a lightweight object for iterating over all data in the grid that also provides indices. More...
 
Array2DCIterator< Type > begin () const
 
Array2DCIterator< Type > end () const
 
Array2DIterator< Type > begin ()
 
Array2DIterator< Type > end ()
 
Array2DCNeighborIterator< Type > begin_neighbors (int x, int y) const
 
Array2DCNeighborIterator< Type > end_neighbors (int x, int y) const
 

Protected Attributes

QVector< QVector< Type > > data
 

Detailed Description

template<typename Type>
class Array2D< Type >

The Array2D class is basically a 2D implementation of QVector.

Usage: // Construction. arr = Array2D<YourType>(rows, cols).

// Access. arr(r,c) = obj;

It is possible to iterate through the Array2D using a for-each loop, as so: for (Type obj : array) { ... }

In the above, there is no guaranteed order of traversal.

Member Typedef Documentation

◆ IndexCollection

template<typename Type>
using Array2D< Type >::IndexCollection = Array2D_Private::Array2DPointWrapper

◆ IndexedConstDataCollection

Constructor & Destructor Documentation

◆ Array2D() [1/4]

template<typename Type>
Array2D< Type >::Array2D ( )
inline

◆ Array2D() [2/4]

template<typename Type>
Array2D< Type >::Array2D ( int  rows,
int  cols,
Type  defaultValue 
)
inline

◆ Array2D() [3/4]

template<typename Type>
Array2D< Type >::Array2D ( int  rows,
int  cols 
)
inline

◆ Array2D() [4/4]

template<typename Type>
Array2D< Type >::Array2D ( QSize  size)
inline

Member Function Documentation

◆ begin() [1/2]

template<typename Type>
Array2DCIterator<Type> Array2D< Type >::begin ( ) const
inline

◆ begin() [2/2]

template<typename Type>
Array2DIterator<Type> Array2D< Type >::begin ( )
inline

◆ begin_neighbors()

template<typename Type>
Array2DCNeighborIterator<Type> Array2D< Type >::begin_neighbors ( int  x,
int  y 
) const
inline

◆ end() [1/2]

template<typename Type>
Array2DCIterator<Type> Array2D< Type >::end ( ) const
inline

◆ end() [2/2]

template<typename Type>
Array2DIterator<Type> Array2D< Type >::end ( )
inline

◆ end_neighbors()

template<typename Type>
Array2DCNeighborIterator<Type> Array2D< Type >::end_neighbors ( int  x,
int  y 
) const
inline

◆ height()

template<typename Type>
int Array2D< Type >::height ( ) const
inline
Here is the caller graph for this function:

◆ indexedData()

template<typename Type>
IndexedConstDataCollection Array2D< Type >::indexedData ( ) const
inline

indexedData Returns a lightweight object for iterating over all data in the grid that also provides indices.

Returns
An object with begin() and end() methods that return iterators that, when dereferenced, return QPair<int, const Type &>.

◆ indices()

template<typename Type>
IndexCollection Array2D< Type >::indices ( ) const
inline

indices Returns a lightweight object for iterating over all valid (x,y) pairs.

Returns
An object with begin() and end() methods that return iterators that loop over valid (x,y) pairs in this array, represented as QPoints.
Here is the caller graph for this function:

◆ isInBounds()

template<typename Type>
bool Array2D< Type >::isInBounds ( QPoint  p) const
inline

Returns true if (p.x(), p.y()) is a valid region.

Parameters
pThe point.

◆ operator()() [1/4]

template<typename Type>
const Type& Array2D< Type >::operator() ( int  r,
int  c 
) const
inline

◆ operator()() [2/4]

template<typename Type>
Type& Array2D< Type >::operator() ( int  r,
int  c 
)
inline

◆ operator()() [3/4]

template<typename Type>
const Type& Array2D< Type >::operator() ( QPoint  p) const
inline

◆ operator()() [4/4]

template<typename Type>
Type& Array2D< Type >::operator() ( QPoint  p)
inline

◆ resize()

template<typename Type>
void Array2D< Type >::resize ( int  rows,
int  cols 
)
inline
Here is the caller graph for this function:

◆ size()

template<typename Type>
QSize Array2D< Type >::size ( ) const
inline
Here is the caller graph for this function:

◆ width()

template<typename Type>
int Array2D< Type >::width ( ) const
inline
Here is the caller graph for this function:

Member Data Documentation

◆ data

template<typename Type>
QVector<QVector<Type> > Array2D< Type >::data
protected

The documentation for this class was generated from the following file: