template<class type_t>
class xtd::collections::generic::ienumerator< type_t >
Supports a simple iteration over a generic collection.
- Definition
template<class type_t>
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
#define interface_
This keyword is use to represent an interface.
Definition interface.hpp:58
- Header
#include <xtd/collections/generic/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;
};
static constexpr type_t max_value
Represents the largest possible value of type_t. This field is constant.
Definition box_integer.hpp:67
virtual bool move_next()=0
Advances the enumerator to the next element of the collection.
virtual const type_t & current() const =0
Gets the element in the collection at the current position of the enumerator.
virtual void reset()=0
Sets the enumerator to its initial position, which is before the first element in the collection.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
Represents a boxed object.
Definition box.hpp:57
- Examples
- generic_icollection.cpp, generic_ienumerable.cpp, generic_ienumerable2.cpp, generic_ienumerator.cpp, and generic_ilist.cpp.