HighMap library (C++)
Loading...
Searching...
No Matches
hmap::CellPath Class Reference

Ordered path of grid cell indices. More...

#include <cell_path.hpp>

Public Member Functions

 CellPath ()=default
 Construct a new CellPath object.
 CellPath (const std::vector< glm::ivec2 > &indices)
 Construct a path by copying cell indices.
 CellPath (std::vector< glm::ivec2 > &&indices) noexcept
 Construct a path by moving cell indices.
std::vector< glm::ivec2 >::iterator begin () noexcept
 Return an iterator to the beginning.
std::vector< glm::ivec2 >::const_iterator begin () const noexcept
 Return a const iterator to the beginning.
std::vector< glm::ivec2 >::iterator end () noexcept
 Return an iterator to the end.
std::vector< glm::ivec2 >::const_iterator end () const noexcept
 Return a const iterator to the end.
glm::ivec2 & front ()
 Access the first element.
const glm::ivec2 & front () const
 Access the first element (const).
glm::ivec2 & back ()
 Access the last element.
const glm::ivec2 & back () const
 Access the last element (const).
glm::ivec2 & operator[] (size_t index)
 Access element by index.
const glm::ivec2 & operator[] (size_t index) const
 Access element by index (const).
void clear () noexcept
 Clear all cell indices.
bool empty () const noexcept
 Check whether the cell path is empty.
void push_back (const glm::ivec2 &idx)
 Add a cell index to the end of the path.
size_t size () const noexcept
 Get the number of cells in the path.
std::vector< glm::ivec2 > & get_indices ()
 Get the cell indices.
const std::vector< glm::ivec2 > & get_indices () const
 Get the cell indices.

Detailed Description

Ordered path of grid cell indices.

Stores a sequence of 2D integer coordinates (i, j) representing a path through a grid or array.

Constructor & Destructor Documentation

◆ CellPath() [1/3]

hmap::CellPath::CellPath ( )
default

Construct a new CellPath object.

◆ CellPath() [2/3]

hmap::CellPath::CellPath ( const std::vector< glm::ivec2 > & indices)

Construct a path by copying cell indices.

Parameters
indicesOrdered cell indices.

◆ CellPath() [3/3]

hmap::CellPath::CellPath ( std::vector< glm::ivec2 > && indices)
noexcept

Construct a path by moving cell indices.

Parameters
indicesOrdered cell indices.

Member Function Documentation

◆ begin() [1/2]

std::vector< glm::ivec2 >::iterator hmap::CellPath::begin ( )
noexcept

Return an iterator to the beginning.

◆ begin() [2/2]

std::vector< glm::ivec2 >::const_iterator hmap::CellPath::begin ( ) const
noexcept

Return a const iterator to the beginning.

◆ end() [1/2]

std::vector< glm::ivec2 >::iterator hmap::CellPath::end ( )
noexcept

Return an iterator to the end.

◆ end() [2/2]

std::vector< glm::ivec2 >::const_iterator hmap::CellPath::end ( ) const
noexcept

Return a const iterator to the end.

◆ front() [1/2]

glm::ivec2 & hmap::CellPath::front ( )

Access the first element.

◆ front() [2/2]

const glm::ivec2 & hmap::CellPath::front ( ) const

Access the first element (const).

◆ back() [1/2]

glm::ivec2 & hmap::CellPath::back ( )

Access the last element.

◆ back() [2/2]

const glm::ivec2 & hmap::CellPath::back ( ) const

Access the last element (const).

◆ operator[]() [1/2]

glm::ivec2 & hmap::CellPath::operator[] ( size_t index)

Access element by index.

Parameters
indexElement index.

◆ operator[]() [2/2]

const glm::ivec2 & hmap::CellPath::operator[] ( size_t index) const

Access element by index (const).

Parameters
indexElement index.

◆ clear()

void hmap::CellPath::clear ( )
noexcept

Clear all cell indices.

◆ empty()

bool hmap::CellPath::empty ( ) const
noexcept

Check whether the cell path is empty.

Returns
True if empty, false otherwise.

◆ push_back()

void hmap::CellPath::push_back ( const glm::ivec2 & idx)

Add a cell index to the end of the path.

Parameters
idxGrid cell index to append.

◆ size()

size_t hmap::CellPath::size ( ) const
noexcept

Get the number of cells in the path.

Returns
Number of cell indices.

◆ get_indices() [1/2]

std::vector< glm::ivec2 > & hmap::CellPath::get_indices ( )

Get the cell indices.

Returns
Mutable reference to the indices.

◆ get_indices() [2/2]

const std::vector< glm::ivec2 > & hmap::CellPath::get_indices ( ) const

Get the cell indices.

Returns
Const reference to the indices.

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