Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
hgps::Map2d< TROW, TCOL, TCell > Class Template Reference

Defines the two-dimensional map (lookup table) data type. More...

#include <map2d.h>

Public Types

using IteratorType = typename std::map< TROW, std::map< TCOL, TCell > >::iterator
 Map row iterator. More...
 
using ConstIteratorType = typename std::map< TROW, std::map< TCOL, TCell > >::const_iterator
 Read-only map iterator. More...
 

Public Member Functions

 Map2d ()=default
 Initialises a new instance of the Map2d class. More...
 
 Map2d (std::map< TROW, std::map< TCOL, TCell >> &&data) noexcept
 Initialises a new instance of the Map2d class. More...
 
bool empty () const noexcept
 Determine whether the container is empty. More...
 
std::size_t size () const noexcept
 Gets the total size of the container dataset. More...
 
std::size_t rows () const noexcept
 Gets the number of rows. More...
 
std::size_t columns () const noexcept
 Gets the number of columns. More...
 
bool contains (const TROW &row_key) const
 Determines whether the container contains a row. More...
 
bool contains (const TROW &row_key, const TCOL &col_key) const
 Determines whether the container contains a value. More...
 
std::map< TCOL, TCell > & row (const TROW &row_key)
 Gets a row dataset. More...
 
const std::map< TCOL, TCell > & row (const TROW &row_key) const
 Gets a read-row dataset. More...
 
TCell & at (const TROW &row_key, const TCOL &col_key)
 Gets a value at a cell by row and column with bounds checking. More...
 
const TCell & at (const TROW &row_key, const TCOL &col_key) const
 Gets a read-only value at a cell by row and column with bounds checking. More...
 
IteratorType begin () noexcept
 Gets an iterator to the beginning of the map. More...
 
IteratorType end () noexcept
 Gets an iterator to the element following the element of the map. More...
 
ConstIteratorType begin () const noexcept
 Gets an read-only iterator to the beginning of the map. More...
 
ConstIteratorType end () const noexcept
 Gets an read-only iterator to the element following the element of the map. More...
 
ConstIteratorType cbegin () const noexcept
 Gets an read-only iterator to the beginning of the map. More...
 
ConstIteratorType cend () const noexcept
 Gets an read-only iterator to the element following the element of the map. More...
 

Detailed Description

template<class TROW, class TCOL, class TCell>
class hgps::Map2d< TROW, TCOL, TCell >

Defines the two-dimensional map (lookup table) data type.

Template Parameters
TROWRows date type
TCOLColumns data type
TCellCell value data type

Member Typedef Documentation

◆ ConstIteratorType

template<class TROW , class TCOL , class TCell >
using hgps::Map2d< TROW, TCOL, TCell >::ConstIteratorType = typename std::map<TROW, std::map<TCOL, TCell> >::const_iterator

Read-only map iterator.

◆ IteratorType

template<class TROW , class TCOL , class TCell >
using hgps::Map2d< TROW, TCOL, TCell >::IteratorType = typename std::map<TROW, std::map<TCOL, TCell> >::iterator

Map row iterator.

Constructor & Destructor Documentation

◆ Map2d() [1/2]

template<class TROW , class TCOL , class TCell >
hgps::Map2d< TROW, TCOL, TCell >::Map2d ( )
default

Initialises a new instance of the Map2d class.

◆ Map2d() [2/2]

template<class TROW , class TCOL , class TCell >
hgps::Map2d< TROW, TCOL, TCell >::Map2d ( std::map< TROW, std::map< TCOL, TCell >> &&  data)
inlinenoexcept

Initialises a new instance of the Map2d class.

Parameters
dataThe lookup table data

Member Function Documentation

◆ at() [1/2]

template<class TROW , class TCOL , class TCell >
TCell& hgps::Map2d< TROW, TCOL, TCell >::at ( const TROW &  row_key,
const TCOL &  col_key 
)
inline

Gets a value at a cell by row and column with bounds checking.

Parameters
row_keyThe row identifier
col_keyThe column identifier
Returns
The cell value

◆ at() [2/2]

template<class TROW , class TCOL , class TCell >
const TCell& hgps::Map2d< TROW, TCOL, TCell >::at ( const TROW &  row_key,
const TCOL &  col_key 
) const
inline

Gets a read-only value at a cell by row and column with bounds checking.

Parameters
row_keyThe row identifier
col_keyThe column identifier
Returns
The read-only cell value

◆ begin() [1/2]

template<class TROW , class TCOL , class TCell >
ConstIteratorType hgps::Map2d< TROW, TCOL, TCell >::begin ( ) const
inlinenoexcept

Gets an read-only iterator to the beginning of the map.

Returns
Iterator to the first element

◆ begin() [2/2]

template<class TROW , class TCOL , class TCell >
IteratorType hgps::Map2d< TROW, TCOL, TCell >::begin ( )
inlinenoexcept

Gets an iterator to the beginning of the map.

Returns
Iterator to the first element

◆ cbegin()

template<class TROW , class TCOL , class TCell >
ConstIteratorType hgps::Map2d< TROW, TCOL, TCell >::cbegin ( ) const
inlinenoexcept

Gets an read-only iterator to the beginning of the map.

Returns
Iterator to the first element

◆ cend()

template<class TROW , class TCOL , class TCell >
ConstIteratorType hgps::Map2d< TROW, TCOL, TCell >::cend ( ) const
inlinenoexcept

Gets an read-only iterator to the element following the element of the map.

Returns
Iterator to the element following the last element.

◆ columns()

template<class TROW , class TCOL , class TCell >
std::size_t hgps::Map2d< TROW, TCOL, TCell >::columns ( ) const
inlinenoexcept

Gets the number of columns.

Returns
Number of columns
Here is the caller graph for this function:

◆ contains() [1/2]

template<class TROW , class TCOL , class TCell >
bool hgps::Map2d< TROW, TCOL, TCell >::contains ( const TROW &  row_key) const
inline

Determines whether the container contains a row.

Parameters
row_keyThe row identifier
Returns
true, if the contains the row; otherwise, false
Here is the caller graph for this function:

◆ contains() [2/2]

template<class TROW , class TCOL , class TCell >
bool hgps::Map2d< TROW, TCOL, TCell >::contains ( const TROW &  row_key,
const TCOL &  col_key 
) const
inline

Determines whether the container contains a value.

Parameters
row_keyThe row identifier
col_keyThe column identifier
Returns
true, if the contains the row; otherwise, false

◆ empty()

template<class TROW , class TCOL , class TCell >
bool hgps::Map2d< TROW, TCOL, TCell >::empty ( ) const
inlinenoexcept

Determine whether the container is empty.

Returns
true, if the container is empty; otherwise, false.
Here is the caller graph for this function:

◆ end() [1/2]

template<class TROW , class TCOL , class TCell >
ConstIteratorType hgps::Map2d< TROW, TCOL, TCell >::end ( ) const
inlinenoexcept

Gets an read-only iterator to the element following the element of the map.

Returns
Iterator to the element following the last element.

◆ end() [2/2]

template<class TROW , class TCOL , class TCell >
IteratorType hgps::Map2d< TROW, TCOL, TCell >::end ( )
inlinenoexcept

Gets an iterator to the element following the element of the map.

Returns
Iterator to the element following the last element.

◆ row() [1/2]

template<class TROW , class TCOL , class TCell >
std::map<TCOL, TCell>& hgps::Map2d< TROW, TCOL, TCell >::row ( const TROW &  row_key)
inline

Gets a row dataset.

Parameters
row_keyThe row identifier
Returns
Row dataset

◆ row() [2/2]

template<class TROW , class TCOL , class TCell >
const std::map<TCOL, TCell>& hgps::Map2d< TROW, TCOL, TCell >::row ( const TROW &  row_key) const
inline

Gets a read-row dataset.

Parameters
row_keyThe row identifier
Returns
Row dataset

◆ rows()

template<class TROW , class TCOL , class TCell >
std::size_t hgps::Map2d< TROW, TCOL, TCell >::rows ( ) const
inlinenoexcept

Gets the number of rows.

Returns
Number of rows
Here is the caller graph for this function:

◆ size()

template<class TROW , class TCOL , class TCell >
std::size_t hgps::Map2d< TROW, TCOL, TCell >::size ( ) const
inlinenoexcept

Gets the total size of the container dataset.

Returns
Total size
Here is the call graph for this function:

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