ForEachIterator< ITERATOR, SUPER > Class Template Reference Data Structures
#include <foreach.h>
ForEachIterator is a helper template for the implementation of a foreach iterator (see maxon::Iterable ). You can use it as public base class for your foreach iterator class with the template argument ITERATOR being your class as in
class MyForEachIterator : public ForEachIterator <MyForEachIterator> { public : void operator ++ (); explicit operator Bool () const ; String & operator * () const ; String * operator ->() const ; };This relieves you from the need to declare a IsForEachIterator type alias, and it adds some functions such as ToString and Contains. However note that these functions are non-const, i.e., they use the current iterator for the iteration so that it will point to another iteration value after function completion.
ITERATOR | The class which implements the foreach protocol, ForEachIterator should be its base class. |
SUPER | This is used as base class of ForEachIterator . |
Classes |
|
class | Wrapper |
Public Types |
|
using | IsForEachIterator = std::true_type |
公共成员函数 |
|
template<typename... ARGS> | |
MAXON_ATTRIBUTE_FORCE_INLINE | ForEachIterator (ARGS &&... args) |
String | ToString (const FormatStatement *formatStatement=nullptr) |
template<typename T > | |
ITERATOR & | Find (const T &v) |
template<typename T > | |
Int | FindIndex (const T &v) |
template<typename T > | |
MAXON_ATTRIBUTE_FORCE_INLINE Bool | Contains (const T &v) |
MAXON_ATTRIBUTE_FORCE_INLINE Wrapper | begin () |
静态公共成员函数 |
|
static MAXON_ATTRIBUTE_FORCE_INLINE | PRIVATE_MAXON_RBF_SENTINEL ( Wrapper ) end () |
using IsForEachIterator = std::true_type |
This marker indicates that this ForEachIterator supports the foreach protocol (see Iterable ).
|
explicit |
ITERATOR& Find | ( | const T & | v | ) |
Iterates over this foreach iterator until an iteration value is found which equals v. The function advances this iterator. Example:
MyForEachIterator it = ...; while (it.Find(value)) { ... do something with *it (which equals value) ...; }[in] | v | Value for comparison. |
Int FindIndex | ( | const T & | v | ) |
Iterates over this foreach iterator until an iteration value is found which equals v, and returns the number of needed iterations or a negative value if v couldn't be found.
[in] | v | Value for comparison. |
MAXON_ATTRIBUTE_FORCE_INLINE Bool Contains | ( | const T & | v | ) |
Iterates over this foreach iterator until an iteration value is found which equals v and returns true on success, or false if v couldn't be found.
[in] | v | Value for comparison. |
MAXON_ATTRIBUTE_FORCE_INLINE Wrapper begin | ( | ) |
|
static |