(Note: This requires C++11)
STL inspired implementaion of a two dimensional array.
There are two main classes, array2d and static_array2d.
Both classes provide three types of iterators, all of which are random access iterators.
The three types are:
- iterator and const_iterator, for iterating over the entire data structure.
- row_iterator and const_row_iterator, for iterating across a particular row.
- column_iterator and const_column_iterator, for iterating down a particular column.
This is a heap allocated generic two dimensional array.
template <typename T>
class array2d
T must be default constructible
- value_type
- pointer
- const_pointer
- reference
- const_reference
- size_type
- iterator
- const_iterator
- row_iterator
- const_row_iterator
- column_iterator
- const_column_iterator
array2d() = delete
array2d is not default constructiblearray2d(size_t width, size_t height)~array2d()array2d(const array2d&)array2d& operator=(const array2d&)array2d(array2d&&)array2d& operator=(array2d&&)size_type width() constsize_type height() const
iterator begin()const_iterator begin() constiterator end()const_iterator end() constrow_iterator row_begin(size_type y)const_row_iterator row_begin(size_type y) constrow_iterator row_end(size_type y)const_row_iterator row_end(size_type y) constcolumn_iterator column_begin(size_type x)const_column_iterator column_begin(size_type x) constcolumn_iterator column_end(size_type x)const_column_iterator column_end(size_type x) const
reference index(size_type x, size_type y)const_reference index(size_type x, size_type y) constreference operator()(size_type x, size_type y)const_reference operator()(size_type x, size_type y) const
template <typename... Args>
iterator emplace(size_type x, size_type y, Args&&... args)template <typename... Args>
iterator emplace(iterator pos, Args&&... args)template <typename... Args>
column_iterator emplace(column_iterator pos, Args&&... args)
This is a stack allocated generic two dimensional array.
template <typename T, std::size_t Width, std::size_t Height>
class static_array2d
T must be default and copy constructible.
- value_type
- pointer
- const_pointer
- reference
- const_reference
- size_type
- iterator
- const_iterator
- row_iterator
- const_row_iterator
- column_iterator
- const_column_iterator
- width
- height
- size
static_array2d()~static_array2d()static_array2d(const static_array2d&)static_array2d& operator=(const static_array2d&)static_array2d(array2d&&)static_array2d& operator=(array2d&&)
iterator begin()const_iterator begin() constiterator end()const_iterator end() constrow_iterator row_begin(size_type y)const_row_iterator row_begin(size_type y) constrow_iterator row_end(size_type y)const_row_iterator row_end(size_type y) constcolumn_iterator column_begin(size_type x)const_column_iterator column_begin(size_type x) constcolumn_iterator column_end(size_type x)const_column_iterator column_end(size_type x) const
reference index(size_type x, size_type y)const_reference index(size_type x, size_type y) constreference operator()(size_type x, size_type y)const_reference operator()(size_type x, size_type y) const
template <typename... Args>
iterator emplace(size_type x, size_type y, Args&&... args)template <typename... Args>
iterator emplace(iterator pos, Args&&... args)template <typename... Args>
column_iterator emplace(column_iterator pos, Args&&... args)