EraseIterator< COLLECTION, SWAP_ERASE, IS_FOREACH_ITERATOR > Class Template Reference

#include <foreach.h>

Inheritance diagram for EraseIterator< COLLECTION, SWAP_ERASE, IS_FOREACH_ITERATOR >:

Detailed Description

template<typename COLLECTION, Bool SWAP_ERASE, Bool IS_FOREACH_ITERATOR = IsForEachIterator<typename COLLECTION::Iterator>::value>
class maxon::EraseIterator< COLLECTION, SWAP_ERASE, IS_FOREACH_ITERATOR >

An EraseIterator is returned by Iterable::EraseIterator. It provides the Erase function which allows to erase the current iteration value from the underlying collection.

See also
Iterable::EraseIterator
Iterable::SwapEraseIterator

Public Types

using Super = ForEachIterator< EraseIterator, typename COLLECTION::Iterator >
 
- Public Types inherited from ForEachIterator< EraseIterator< COLLECTION, SWAP_ERASE, IsForEachIterator< typename COLLECTION::Iterator >::value >, COLLECTION::Iterator >
using IsForEachIterator = std::true_type
 

Public Member Functions

 EraseIterator (COLLECTION &collection)
 
 EraseIterator (EraseIterator &&src)
 
template<typename... ARGS>
void Erase (ARGS &&... args)
 
void operator++ ()
 
void operator++ (int)
 
- Public Member Functions inherited from ForEachIterator< EraseIterator< COLLECTION, SWAP_ERASE, IsForEachIterator< typename COLLECTION::Iterator >::value >, COLLECTION::Iterator >
MAXON_ATTRIBUTE_FORCE_INLINE ForEachIterator (ARGS &&... args)
 
String ToString (const FormatStatement *formatStatement=nullptr)
 
EraseIterator< COLLECTION, SWAP_ERASE, IsForEachIterator< typename COLLECTION::Iterator >::value > & Find (const T &v)
 
Int FindIndex (const T &v)
 
MAXON_ATTRIBUTE_FORCE_INLINE Bool Contains (const T &v)
 
MAXON_ATTRIBUTE_FORCE_INLINE Wrapper begin ()
 

Private Member Functions

void operator-- ()
 
void operator-- (int)
 
void operator+= (int)
 
void operator-= (int)
 
void operator+ (int)
 
void operator- (int)
 
 MAXON_DISALLOW_COPY_AND_ASSIGN (EraseIterator)
 

Private Attributes

COLLECTION * _collection
 
Bool _erased
 

Additional Inherited Members

- Static Public Member Functions inherited from ForEachIterator< EraseIterator< COLLECTION, SWAP_ERASE, IsForEachIterator< typename COLLECTION::Iterator >::value >, COLLECTION::Iterator >
static MAXON_ATTRIBUTE_FORCE_INLINE PRIVATE_MAXON_RBF_SENTINEL (Wrapper) end()
 

Member Typedef Documentation

◆ Super

using Super = ForEachIterator<EraseIterator, typename COLLECTION::Iterator>

Constructor & Destructor Documentation

◆ EraseIterator() [1/2]

EraseIterator ( COLLECTION &  collection)
explicit

◆ EraseIterator() [2/2]

EraseIterator ( EraseIterator< COLLECTION, SWAP_ERASE, IS_FOREACH_ITERATOR > &&  src)

Member Function Documentation

◆ Erase()

void Erase ( ARGS &&...  args)

Removes the current iteration value from the underlying collection. This is a simple and safe way to remove a value from a collection within a for loop. You must not access the removed iteration value afterwards, the only valid operation on an iterator after Erase is ++iterator. Example:

for (auto it = Iterable::EraseIterator(array); it; ++it)
{
if (*it == valueToErase)
it.Erase();
}
static MAXON_ATTRIBUTE_FORCE_INLINE maxon::EraseIterator< COLLECTION, false > EraseIterator(COLLECTION &c)
Definition: foreach.h:1343

◆ operator++() [1/2]

void operator++ ( )

◆ operator++() [2/2]

void operator++ ( int  )

◆ operator--() [1/2]

void operator-- ( )
private

◆ operator--() [2/2]

void operator-- ( int  )
private

◆ operator+=()

void operator+= ( int  )
private

◆ operator-=()

void operator-= ( int  )
private

◆ operator+()

void operator+ ( int  )
private

◆ operator-()

void operator- ( int  )
private

◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( EraseIterator< COLLECTION, SWAP_ERASE, IS_FOREACH_ITERATOR >  )
private

Member Data Documentation

◆ _collection

COLLECTION* _collection
private

◆ _erased

Bool _erased
private