template<typename type_t>
class xtd::collections::generic::ienumerator< type_t >
Supports a simple iteration over a generic collection.
- Definition
template<typename type_t>
Supports a simple iteration over a generic collection.
Definition ienumerator.h:58
#define interface_
This keyword is use to represent an interface.
Definition interface.h:58
- Header
#include <xtd/collections/ienumerator
- Namespace
- xtd::collections::generic
- Library
- xtd.core
- Examples
- The following example shows an implementation of the xtd::collections::generic::ienumerator <type_t> interface for a collection class of custom objects. The custom object is an instance of the type Box, and the collection class is BoxCollection. This code example is part of a larger example provided for the ICollection<T> interface.
public:
explicit box_enumerator(const box_collection& boxes) : boxes {boxes} {}
const box& current()
const override {
return boxes[cur_index];}
bool move_next() override {return ++cur_index < boxes.count() ? true : false;}
private:
const box_collection& boxes;
size cur_index = box_integer<size>::max_value;
};
Represents a boxed integer object.
Definition box_integer.h:52
Represents a boxed object.
Definition box.h:53
|
virtual const type_t & | current () const =0 |
| Gets the element in the collection at the current position of the enumerator.
|
|
|
virtual bool | move_next ()=0 |
| Advances the enumerator to the next element of the collection.
|
|
virtual void | reset ()=0 |
| Sets the enumerator to its initial position, which is before the first element in the collection.
|
|
The documentation for this class was generated from the following file: