mcpp
C++ Minecraft Library
mcpp::HeightMap::Iterator Struct Reference

An iterator for the HeightMap structure. More...

#include <util.h>

Public Types

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

Public Member Functions

 Iterator (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...
 
Iteratoroperator++ ()
 Pre-increment operator. Advances the iterator to the next position. More...
 
Iterator operator++ (int)
 Post-increment operator. Advances the iterator to the next position. More...
 

Friends

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

Detailed Description

An iterator for the HeightMap structure.

This iterator allows for range-based for loops and standard iterator operations over the height data stored within a HeightMap.

Member Typedef Documentation

◆ difference_type

◆ iterator_category

using mcpp::HeightMap::Iterator::iterator_category = std::forward_iterator_tag

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ Iterator()

mcpp::HeightMap::Iterator::Iterator ( 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::HeightMap::Iterator::operator* ( ) const
inline

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

Returns
Reference to the current element.

◆ operator++() [1/2]

Iterator& mcpp::HeightMap::Iterator::operator++ ( )
inline

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

Returns
Reference to the updated iterator.

◆ operator++() [2/2]

Iterator mcpp::HeightMap::Iterator::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::HeightMap::Iterator::operator-> ( )
inline

Access the pointer to the current element.

Returns
Pointer to the current element.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Iterator a,
const Iterator 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 Iterator a,
const Iterator 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: