stmm-games-doc  0.32.0
Classes | Public Member Functions | Protected Member Functions | List of all members
stmg::Coords Class Reference

Coords class. More...

Inheritance diagram for stmg::Coords:
Inheritance graph
[legend]

Classes

class  const_iterator
 Coords iterator. More...
 

Public Member Functions

 Coords () noexcept
 Constructor. More...
 
 Coords (int32_t nAtLeastSize) noexcept
 Constructor. More...
 
void reInit () noexcept
 Clears the instance. More...
 
void reInit (int32_t nAtLeastSize) noexcept
 Clears the instance. More...
 
int32_t size () const noexcept
 The number of (unique) coords in the instance. More...
 
bool isEmpty () const noexcept
 Whether set is empty. More...
 
void add (int32_t nX, int32_t nY) noexcept
 Add a coord. More...
 
void add (NPoint oXY) noexcept
 Add a coord. More...
 
void addRect (int32_t nX, int32_t nY, int32_t nW, int32_t nH) noexcept
 Add all cords in a rectangle. More...
 
void addRect (NRect oRect) noexcept
 Add all cords in a rectangle. More...
 
bool contains (int32_t nX, int32_t nY) const noexcept
 Whether the instance contains a coord. More...
 
bool contains (NPoint oXY) const noexcept
 Whether the instance contains a coord. More...
 
bool remove (int32_t nX, int32_t nY) noexcept
 Removes a coord if it exists. More...
 
bool remove (NPoint oXY) noexcept
 Removes a coord if it exists. More...
 
void removeInRect (int32_t nX, int32_t nY, int32_t nW, int32_t nH) noexcept
 Remove all coords within a rect. More...
 
void removeInRect (NRect oRect) noexcept
 Add all cords in a rectangle. More...
 
NRect getMinMax () const noexcept
 Get the smallest recangle containing all the coords. More...
 
void add (const Coords &oCoords) noexcept
 Add another coords to this instance. More...
 
void remove (const Coords &oCoords) noexcept
 Remove all the coords of another instance,. More...
 
const_iterator begin () const noexcept
 
Coords::const_iterator end () const noexcept
 
bool remove (const const_iterator &it) noexcept
 

Protected Member Functions

 Coords (bool bTileCoords) noexcept
 
 Coords (bool bTileCoords, int32_t nAtLeastSize) noexcept
 
const_iterator find (int32_t nX, int32_t nY) const noexcept
 Returns the iterator. More...
 
int32_t & getOrCreate (NPoint oXY) noexcept
 
void clearData (int32_t nAtLeastSize) noexcept
 

Detailed Description

Coords class.

Beware! This class is final, only meant to be subclassed by TileCoords.

Constructor & Destructor Documentation

◆ Coords() [1/4]

stmg::Coords::Coords ( )
noexcept

Constructor.

◆ Coords() [2/4]

stmg::Coords::Coords ( int32_t  nAtLeastSize)
explicitnoexcept

Constructor.

Parameters
nAtLeastSizeThe indicative minimum number of unique values.

◆ Coords() [3/4]

stmg::Coords::Coords ( bool  bTileCoords)
explicitprotectednoexcept

◆ Coords() [4/4]

stmg::Coords::Coords ( bool  bTileCoords,
int32_t  nAtLeastSize 
)
protectednoexcept

Member Function Documentation

◆ add() [1/3]

void stmg::Coords::add ( int32_t  nX,
int32_t  nY 
)
noexcept

Add a coord.

Might invalidate iterators.

Parameters
nXThe x.
nYThe y.

◆ add() [2/3]

void stmg::Coords::add ( NPoint  oXY)
noexcept

Add a coord.

Might invalidate iterators.

Parameters
oXYThe coord to add.

◆ add() [3/3]

void stmg::Coords::add ( const Coords oCoords)
noexcept

Add another coords to this instance.

Parameters
oCoordsThee coords to add.

◆ addRect() [1/2]

void stmg::Coords::addRect ( int32_t  nX,
int32_t  nY,
int32_t  nW,
int32_t  nH 
)
noexcept

Add all cords in a rectangle.

Might invalidate iterators.

Example: add(1,2,2,1) adds coords (1,2), (2,2).

Parameters
nXThe x.
nYThe y.
nWThe width. Must be > 0.
nHThe height. Must be > 0.

◆ addRect() [2/2]

void stmg::Coords::addRect ( NRect  oRect)
noexcept

Add all cords in a rectangle.

See addRect(int32_t nX, int32_t nY, int32_t nW, int32_t nH).

Parameters
oRectThe rectangle.

◆ begin()

const_iterator stmg::Coords::begin ( ) const
inlinenoexcept

◆ clearData()

void stmg::Coords::clearData ( int32_t  nAtLeastSize)
protectednoexcept

◆ contains() [1/2]

bool stmg::Coords::contains ( int32_t  nX,
int32_t  nY 
) const
noexcept

Whether the instance contains a coord.

Parameters
nXThe x.
nYThe y.
Returns
Whether the instance contains a ccord.

◆ contains() [2/2]

bool stmg::Coords::contains ( NPoint  oXY) const
noexcept

Whether the instance contains a coord.

Parameters
oXYThe coord.
Returns
Whether the instance contains a ccord.

◆ end()

Coords::const_iterator stmg::Coords::end ( ) const
inlinenoexcept

◆ find()

const_iterator stmg::Coords::find ( int32_t  nX,
int32_t  nY 
) const
protectednoexcept

Returns the iterator.

Parameters
nXThe x.
nYThe y.
Returns
A valid iterator, Coords::end() if not found.

◆ getMinMax()

NRect stmg::Coords::getMinMax ( ) const
noexcept

Get the smallest recangle containing all the coords.

Returns
The rectangle. Has width 0 if this instance is empty.

◆ getOrCreate()

int32_t& stmg::Coords::getOrCreate ( NPoint  oXY)
protectednoexcept

◆ isEmpty()

bool stmg::Coords::isEmpty ( ) const
noexcept

Whether set is empty.

Returns
Whether empty.

◆ reInit() [1/2]

void stmg::Coords::reInit ( )
noexcept

Clears the instance.

All iterators become invalid.

◆ reInit() [2/2]

void stmg::Coords::reInit ( int32_t  nAtLeastSize)
noexcept

Clears the instance.

All iterators become invalid.

Parameters
nAtLeastSizeThe indicative minimum number of unique values.

◆ remove() [1/4]

bool stmg::Coords::remove ( int32_t  nX,
int32_t  nY 
)
noexcept

Removes a coord if it exists.

Parameters
nXThe x.
nYThe y.
Returns
Whether the coord existed.

◆ remove() [2/4]

bool stmg::Coords::remove ( NPoint  oXY)
noexcept

Removes a coord if it exists.

Parameters
oXYThe coord.
Returns
Whether the coord existed.

◆ remove() [3/4]

void stmg::Coords::remove ( const Coords oCoords)
noexcept

Remove all the coords of another instance,.

Parameters
oCoordsThe coords to remove,

◆ remove() [4/4]

bool stmg::Coords::remove ( const const_iterator it)
noexcept

◆ removeInRect() [1/2]

void stmg::Coords::removeInRect ( int32_t  nX,
int32_t  nY,
int32_t  nW,
int32_t  nH 
)
noexcept

Remove all coords within a rect.

Parameters
nXThe x.
nYThe y.
nWThe width. Must be > 0.
nHThe height. Must be > 0.

◆ removeInRect() [2/2]

void stmg::Coords::removeInRect ( NRect  oRect)
noexcept

Add all cords in a rectangle.

See removeInRect(int32_t nX, int32_t nY, int32_t nW, int32_t nH).

Parameters
oRectThe rectangle.

◆ size()

int32_t stmg::Coords::size ( ) const
noexcept

The number of (unique) coords in the instance.

Returns
The size.