18 template<
typename type_t = std::
nullptr_t>
38 template<
typename type_t>
63 [[nodiscard]]
const type_t&
current()
const override {
return enumerator_->current();}
72 [[nodiscard]]
bool move_next()
override {
return enumerator_->move_next();}
77 void reset()
override {enumerator_->reset();}
114 template<
typename collection_t,
typename version_t = std::
nullptr_t>
115 static auto create(
const collection_t& items,
const version_t* current_version =
nullptr) noexcept {
116 using value_type =
typename collection_t::value_type;
118 struct internal_enumerator :
public ienumerator<value_type> {
120 explicit internal_enumerator(
const collection_t& items,
const version_t* current_version) : items_(items), version_(current_version ? * current_version : version_t {}), current_version_(current_version) {}
122 [[nodiscard]]
const value_type&
current()
const override {
128 [[nodiscard]]
bool move_next()
override {
130 if (index_++ && iterator_ != items_.cend()) ++iterator_;
131 else iterator_ = items_.cbegin();
132 return iterator_ != items_.cend();
135 void reset()
override {
137 version_ = current_version_ ? *current_version_ : version_t {};
138 iterator_ = items_.cend();
143 const collection_t& items_;
145 version_t version_ = version_t {};
146 const version_t* current_version_ =
nullptr;
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains xtd::collections::generic::ienumerator <type_t> interface.
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:38
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > const_iterator
Represents the const iterator of read_only_span value type.
Definition read_only_span.hpp:73
Contains xtd::new_ptr method.
Contains xtd::object class.
Contains xtd::static_object class.
static auto create(const collection_t &items, const version_t *current_version=nullptr) noexcept
Create an enumerator from specified collection and version.
Definition enumerator.hpp:115
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:39
const type_t & current() const override
Gets the element in the collection at the current position of the enumerator.
Definition enumerator.hpp:63
enumerator(ptr< ienumerator< type_t > > enumerator)
Initializes a new instance of the xtd::collections::generic::enumerator <type_t> class with specified...
Definition enumerator.hpp:47
enumerator()=default
Initializes a new instance of the xtd::collections::generic::enumerator <type_t> class.
bool move_next() override
Advances the enumerator to the next element of the collection.
Definition enumerator.hpp:72
void reset() override
Sets the enumerator to its initial position, which is before the first element in the collection.
Definition enumerator.hpp:77
Contains xtd::helpers::throw_helper class.