2.10.0
Freundlich's C++ toolkit
Public Types | Public Member Functions
fcppt::container::grid::object< T, N, A > Class Template Reference

Detailed Description

template<typename T, fcppt::container::grid::size_type N, typename A>
class fcppt::container::grid::object< T, N, A >

A simple n dimensional array.

See the module description for more information.

Public Types

typedef std::integral_constant< fcppt::container::grid::size_type, N > static_size
 
typedef A allocator_type
 
typedef T value_type
 
typedef container::size_type size_type
 
typedef container::difference_type difference_type
 
typedef container::reference reference
 
typedef container::const_reference const_reference
 
typedef container::iterator iterator
 
typedef container::const_iterator const_iterator
 
typedef fcppt::container::grid::dim< size_type, N > dim
 A type representing the dimension of the grid. More...
 
typedef fcppt::container::grid::pos< size_type, N > pos
 A type representing a position in the grid. More...
 
typedef fcppt::container::grid::pos< difference_type, N > signed_pos
 A signed version of pos. More...
 

Public Member Functions

 object ()
 An empty grid. More...
 
 object (dim const &d, value_type const &r)
 Initialize the grid to a size and fill every cell with the same value. More...
 
template<typename Function >
 object (dim const &size, Function const &function)
 Initialize the grid by calling a function for every element. More...
 
 object (object const &)
 
 object (object &&) noexcept(std::is_nothrow_move_constructible< T >::value)
 
objectoperator= (object const &)
 
objectoperator= (object &&) noexcept(std::is_nothrow_move_assignable< T >::value)
 
 ~object ()
 
reference get_unsafe (pos const &)
 Returns a reference to the grid element at a specified position. More...
 
const_reference get_unsafe (pos const &) const
 Returns a reference to the grid element at a specified position. More...
 
dim const & size () const
 Returns the grid's size. More...
 
size_type content () const
 Returns the number of elements in the grid. More...
 
bool empty () const
 Tests if the grid is empty. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void swap (object &)
 Exchanges the elements of two grids. More...
 

Member Typedef Documentation

◆ allocator_type

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef A fcppt::container::grid::object< T, N, A >::allocator_type

◆ const_iterator

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef container::const_iterator fcppt::container::grid::object< T, N, A >::const_iterator

◆ const_reference

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef container::const_reference fcppt::container::grid::object< T, N, A >::const_reference

◆ difference_type

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef container::difference_type fcppt::container::grid::object< T, N, A >::difference_type

◆ dim

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef fcppt::container::grid::dim< size_type, N > fcppt::container::grid::object< T, N, A >::dim

A type representing the dimension of the grid.

◆ iterator

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef container::iterator fcppt::container::grid::object< T, N, A >::iterator

◆ pos

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef fcppt::container::grid::pos< size_type, N > fcppt::container::grid::object< T, N, A >::pos

A type representing a position in the grid.

◆ reference

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef container::reference fcppt::container::grid::object< T, N, A >::reference

◆ signed_pos

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef fcppt::container::grid::pos< difference_type, N > fcppt::container::grid::object< T, N, A >::signed_pos

A signed version of pos.

◆ size_type

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef container::size_type fcppt::container::grid::object< T, N, A >::size_type

◆ static_size

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef std::integral_constant< fcppt::container::grid::size_type, N > fcppt::container::grid::object< T, N, A >::static_size

◆ value_type

template<typename T , fcppt::container::grid::size_type N, typename A >
typedef T fcppt::container::grid::object< T, N, A >::value_type

Constructor & Destructor Documentation

◆ object() [1/5]

template<typename T , fcppt::container::grid::size_type N, typename A >
fcppt::container::grid::object< T, N, A >::object ( )

An empty grid.

◆ object() [2/5]

template<typename T , fcppt::container::grid::size_type N, typename A >
fcppt::container::grid::object< T, N, A >::object ( dim const &  d,
value_type const &  r 
)

Initialize the grid to a size and fill every cell with the same value.

Parameters
dThe size of the grid
rThe value to assign to each element of the grid

◆ object() [3/5]

template<typename T , fcppt::container::grid::size_type N, typename A >
template<typename Function >
fcppt::container::grid::object< T, N, A >::object ( dim const &  size,
Function const &  function 
)

Initialize the grid by calling a function for every element.

Calls function for every position in the grid.

Template Parameters
FunctionA function of type value_type (pos)

◆ object() [4/5]

template<typename T , fcppt::container::grid::size_type N, typename A >
fcppt::container::grid::object< T, N, A >::object ( object< T, N, A > const &  )

◆ object() [5/5]

template<typename T , fcppt::container::grid::size_type N, typename A >
fcppt::container::grid::object< T, N, A >::object ( object< T, N, A > &&  ) const
noexcept

◆ ~object()

template<typename T , fcppt::container::grid::size_type N, typename A >
fcppt::container::grid::object< T, N, A >::~object ( )

Member Function Documentation

◆ begin() [1/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
iterator fcppt::container::grid::object< T, N, A >::begin ( )

◆ begin() [2/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
const_iterator fcppt::container::grid::object< T, N, A >::begin ( ) const

◆ content()

template<typename T , fcppt::container::grid::size_type N, typename A >
size_type fcppt::container::grid::object< T, N, A >::content ( ) const

Returns the number of elements in the grid.

◆ empty()

template<typename T , fcppt::container::grid::size_type N, typename A >
bool fcppt::container::grid::object< T, N, A >::empty ( ) const

Tests if the grid is empty.

◆ end() [1/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
iterator fcppt::container::grid::object< T, N, A >::end ( )

◆ end() [2/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
const_iterator fcppt::container::grid::object< T, N, A >::end ( ) const

◆ get_unsafe() [1/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
reference fcppt::container::grid::object< T, N, A >::get_unsafe ( pos const &  )

Returns a reference to the grid element at a specified position.

Warning
Behaviour is undefined if the position is out of range.

◆ get_unsafe() [2/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
const_reference fcppt::container::grid::object< T, N, A >::get_unsafe ( pos const &  ) const

Returns a reference to the grid element at a specified position.

Warning
Behaviour is undefined if the position is out of range.

◆ operator=() [1/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
object& fcppt::container::grid::object< T, N, A >::operator= ( object< T, N, A > const &  )

◆ operator=() [2/2]

template<typename T , fcppt::container::grid::size_type N, typename A >
object& fcppt::container::grid::object< T, N, A >::operator= ( object< T, N, A > &&  )
noexcept

◆ size()

template<typename T , fcppt::container::grid::size_type N, typename A >
dim const& fcppt::container::grid::object< T, N, A >::size ( ) const

Returns the grid's size.

Note
In contrast to the standard containers, this does not return a size_type value, but the dimension. Use content() to get the number of elements

◆ swap()

template<typename T , fcppt::container::grid::size_type N, typename A >
void fcppt::container::grid::object< T, N, A >::swap ( object< T, N, A > &  )

Exchanges the elements of two grids.