mcpp
C++ Minecraft Library
mcpp::Chunk::ConstIterator Struct Reference

An iterator for the const Chunk's 3D block data. More...

#include <util.h>

Public Types

using iterator_category = std::forward_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = BlockType
 
using pointer = const BlockType *
 
using reference = const BlockType &
 

Public Member Functions

 ConstIterator (pointer ptr)
 Constructs an iterator at the given pointer position. More...
 
reference operator* () const
 Dereference the iterator to access the value at the current position. More...
 
pointer operator-> ()
 Access the pointer to the current element. More...
 
ConstIteratoroperator++ ()
 Pre-increment operator. Advances the iterator to the next position. More...
 
ConstIterator operator++ (int)
 Post-increment operator. Advances the iterator to the next position. More...
 

Friends

bool operator== (const ConstIterator &a, const ConstIterator &b)
 Equality comparison operator. More...
 
bool operator!= (const ConstIterator &a, const ConstIterator &b)
 Inequality comparison operator. More...
 

Detailed Description

An iterator for the const Chunk's 3D block data.

This iterator allows for range-based for loops and standard const iterator operations over the 3D block data stored within a Chunk. It provides a linear interface to traverse the 3D grid of blocks, enabling sequential immutable access to the elements stored in the chunk.

Member Typedef Documentation

◆ difference_type

◆ iterator_category

using mcpp::Chunk::ConstIterator::iterator_category = std::forward_iterator_tag

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ ConstIterator()

mcpp::Chunk::ConstIterator::ConstIterator ( pointer  ptr)
inline

Constructs an iterator at the given pointer position.

Parameters
ptrPointer to the position in the height array.

Member Function Documentation

◆ operator*()

reference mcpp::Chunk::ConstIterator::operator* ( ) const
inline

Dereference the iterator to access the value at the current position.

Returns
Reference to the current element.

◆ operator++() [1/2]

ConstIterator& mcpp::Chunk::ConstIterator::operator++ ( )
inline

Pre-increment operator. Advances the iterator to the next position.

Returns
Reference to the updated iterator.

◆ operator++() [2/2]

ConstIterator mcpp::Chunk::ConstIterator::operator++ ( int  )
inline

Post-increment operator. Advances the iterator to the next position.

Parameters
intUnused dummy parameter to differentiate from prefix increment.
Returns
Iterator to the original position before incrementing.

◆ operator->()

pointer mcpp::Chunk::ConstIterator::operator-> ( )
inline

Access the pointer to the current element.

Returns
Pointer to the current element.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const ConstIterator a,
const ConstIterator b 
)
friend

Inequality comparison operator.

Parameters
aFirst iterator to compare.
bSecond iterator to compare.
Returns
true if iterators point to different positions, false otherwise.

◆ operator==

bool operator== ( const ConstIterator a,
const ConstIterator b 
)
friend

Equality comparison operator.

Parameters
aFirst iterator to compare.
bSecond iterator to compare.
Returns
true if both iterators point to the same position, false otherwise.

The documentation for this struct was generated from the following file: