Gamedev Framework (gf)  0.12.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::Index2D< I > Class Template Reference

A two-dimensional array with no data. More...

#include <gf/Array2D.h>

Inheritance diagram for gf::Index2D< I >:
Inheritance graph
[legend]

Public Member Functions

 Index2D ()
 Default constructor. More...
 
 Index2D (Vector< I, 2 > size)
 Constructor with a size. More...
 
 Index2D (const Index2D &)=default
 Default copy constructor. More...
 
Index2Doperator= (const Index2D &)=default
 Default copy assignment. More...
 
 Index2D (Index2D &&)=default
 Default move constructor. More...
 
Index2Doperator= (Index2D &&)=default
 Default move assignement. More...
 
void swap (Index2D &other)
 Swap with another array. More...
 
Size and position
constexpr Vector< I, 2 > getSize () const noexcept
 Get the size of the array. More...
 
constexpr I getCols () const noexcept
 Get the number of columns. More...
 
constexpr I getRows () const noexcept
 Get the number of rows. More...
 
constexpr bool isValid (Vector< I, 2 > pos) const noexcept
 Check if a position is valid. More...
 
constexpr Vector< I, 2 > toPosition (std::size_t index) const noexcept
 Transform a 1D position into a 2D position. More...
 
constexpr std::size_t toIndex (Vector< I, 2 > pos) const noexcept
 Transform a 2D position into a 1D position. More...
 
Ranges
constexpr RangeZ getIndexRange () const noexcept
 Get the 1D index range of the array. More...
 
constexpr Range< IgetRowRange () const noexcept
 Get the row range. More...
 
constexpr Range< IgetColRange () const noexcept
 Get the column range. More...
 
constexpr PositionRange< IgetPositionRange () const noexcept
 Get the position range. More...
 
NeighborSquareRange< Iget8NeighborsRange (Vector< I, 2 > pos) const noexcept
 Get a range for 8 neighbors (at most) More...
 
NeighborSquareRange< Iget24NeighborsRange (Vector< I, 2 > pos) const noexcept
 Get a range for 24 neighbors (at most) More...
 
NeighborDiamondRange< Iget4NeighborsRange (Vector< I, 2 > pos) const noexcept
 Get a range for 4 neighbors (at most) More...
 
NeighborDiamondRange< Iget12NeighborsRange (Vector< I, 2 > pos) const noexcept
 Get a range for 12 neighbors (at most) More...
 

Detailed Description

template<typename I>
class gf::Index2D< I >

A two-dimensional array with no data.

You probably want to use gf::Array2D

See also
gf::Array2D

Constructor & Destructor Documentation

◆ Index2D() [1/4]

template<typename I>
gf::Index2D< I >::Index2D ( )
inline

Default constructor.

Creates an empty array.

◆ Index2D() [2/4]

template<typename I>
gf::Index2D< I >::Index2D ( Vector< I, 2 >  size)
inline

Constructor with a size.

Parameters
sizeThe size of the array

◆ Index2D() [3/4]

template<typename I>
gf::Index2D< I >::Index2D ( const Index2D< I > &  )
default

Default copy constructor.

◆ Index2D() [4/4]

template<typename I>
gf::Index2D< I >::Index2D ( Index2D< I > &&  )
default

Default move constructor.

Member Function Documentation

◆ get12NeighborsRange()

template<typename I>
NeighborDiamondRange<I> gf::Index2D< I >::get12NeighborsRange ( Vector< I, 2 >  pos) const
inlinenoexcept

Get a range for 12 neighbors (at most)

Parameters
posThe base position
Returns
A range over neighbors (position not included)

◆ get24NeighborsRange()

template<typename I>
NeighborSquareRange<I> gf::Index2D< I >::get24NeighborsRange ( Vector< I, 2 >  pos) const
inlinenoexcept

Get a range for 24 neighbors (at most)

Parameters
posThe base position
Returns
A range over neighbors (position not included)

◆ get4NeighborsRange()

template<typename I>
NeighborDiamondRange<I> gf::Index2D< I >::get4NeighborsRange ( Vector< I, 2 >  pos) const
inlinenoexcept

Get a range for 4 neighbors (at most)

Parameters
posThe base position
Returns
A range over neighbors (position not included)

◆ get8NeighborsRange()

template<typename I>
NeighborSquareRange<I> gf::Index2D< I >::get8NeighborsRange ( Vector< I, 2 >  pos) const
inlinenoexcept

Get a range for 8 neighbors (at most)

Parameters
posThe base position
Returns
A range over neighbors (position not included)

◆ getColRange()

template<typename I>
constexpr Range<I> gf::Index2D< I >::getColRange ( ) const
inlinenoexcept

Get the column range.

Returns
A range with all the columns

◆ getCols()

template<typename I>
constexpr I gf::Index2D< I >::getCols ( ) const
inlinenoexcept

Get the number of columns.

Returns
The number of columns

◆ getIndexRange()

template<typename I>
constexpr RangeZ gf::Index2D< I >::getIndexRange ( ) const
inlinenoexcept

Get the 1D index range of the array.

Returns
A range with all the 1D index in the array

◆ getPositionRange()

template<typename I>
constexpr PositionRange<I> gf::Index2D< I >::getPositionRange ( ) const
inlinenoexcept

Get the position range.

Returns
A range for iterating among the positions

◆ getRowRange()

template<typename I>
constexpr Range<I> gf::Index2D< I >::getRowRange ( ) const
inlinenoexcept

Get the row range.

Returns
A range with all the rows

◆ getRows()

template<typename I>
constexpr I gf::Index2D< I >::getRows ( ) const
inlinenoexcept

Get the number of rows.

Returns
The number of rows

◆ getSize()

template<typename I>
constexpr Vector<I, 2> gf::Index2D< I >::getSize ( ) const
inlinenoexcept

Get the size of the array.

Returns
The size of the array

◆ isValid()

template<typename I>
constexpr bool gf::Index2D< I >::isValid ( Vector< I, 2 >  pos) const
inlinenoexcept

Check if a position is valid.

A valid position is a position inside the array

Returns
True if the position is valid

◆ operator=() [1/2]

template<typename I>
Index2D& gf::Index2D< I >::operator= ( const Index2D< I > &  )
default

Default copy assignment.

◆ operator=() [2/2]

template<typename I>
Index2D& gf::Index2D< I >::operator= ( Index2D< I > &&  )
default

Default move assignement.

◆ swap()

template<typename I>
void gf::Index2D< I >::swap ( Index2D< I > &  other)
inline

Swap with another array.

Parameters
otherAn other array

◆ toIndex()

template<typename I>
constexpr std::size_t gf::Index2D< I >::toIndex ( Vector< I, 2 >  pos) const
inlinenoexcept

Transform a 2D position into a 1D position.

Parameters
posA 2D position
Returns
The corresponding 1D position

◆ toPosition()

template<typename I>
constexpr Vector<I, 2> gf::Index2D< I >::toPosition ( std::size_t  index) const
inlinenoexcept

Transform a 1D position into a 2D position.

Parameters
indexA 1D position
Returns
The corresponding 2D position