3.8.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 >

An n-dimensional array.

See fcppt.container.grid for more information.

Public Types

using static_size = std::integral_constant< fcppt::container::grid::size_type, N >
 
using allocator_type = A
 
using value_type = T
 
using size_type = typename container::size_type
 
using difference_type = typename container::difference_type
 
using reference = typename container::reference
 
using const_reference = typename container::const_reference
 
using iterator = typename container::iterator
 
using const_iterator = typename container::const_iterator
 
using dim = fcppt::container::grid::dim< size_type, N >
 A type representing the dimension of the grid. More...
 
using pos = fcppt::container::grid::pos< size_type, N >
 A type representing a position in the grid. More...
 
using signed_pos = fcppt::container::grid::pos< difference_type, N >
 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...
 
template<typename Arg1 , typename... Args, typename = std::enable_if_t<std::conjunction_v< fcppt::container::grid::is_static_row<Arg1>, fcppt::container::grid::is_static_row<Args>...>>>
 object (Arg1 &&, Args &&...)
 Initialize the grid from a sequence of fcppt::container::grid::static_row_type. More...
 
 object (object const &)
 
 object (object &&) noexcept(std::is_nothrow_move_constructible_v< T >)
 
objectoperator= (object const &)
 
objectoperator= (object &&) noexcept(std::is_nothrow_move_assignable_v< T >)
 
 ~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 >
using fcppt::container::grid::object< T, N, A >::allocator_type = A

◆ const_iterator

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

◆ const_reference

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

◆ difference_type

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

◆ dim

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

A type representing the dimension of the grid.

◆ iterator

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

◆ pos

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

A type representing a position in the grid.

◆ reference

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

◆ signed_pos

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

A signed version of pos.

◆ size_type

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

◆ static_size

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

◆ value_type

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

Constructor & Destructor Documentation

◆ object() [1/6]

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

An empty grid.

◆ object() [2/6]

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/6]

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/6]

template<typename T , fcppt::container::grid::size_type N, typename A >
template<typename Arg1 , typename... Args, typename = std::enable_if_t<std::conjunction_v< fcppt::container::grid::is_static_row<Arg1>, fcppt::container::grid::is_static_row<Args>...>>>
fcppt::container::grid::object< T, N, A >::object ( Arg1 &&  ,
Args &&  ... 
)
explicit

Initialize the grid from a sequence of fcppt::container::grid::static_row_type.

Use fcppt::container::grid::static_row to create a grid row. For example, calling this constructro with static_row(1,2,3),static_row(4,5,6) will yields a grid of size 3x2.

All arguments must have the same size (i.e. row length) and all rows must have value type T.

◆ object() [5/6]

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() [6/6]

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 > &&  )
noexcept

◆ 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 > const &  )

◆ 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.