6#include "../../ptrdiff.h"
13 namespace collections {
43 template<
typename type_t,
typename enumerable_t>
76 begin.enumerable_ = enumerable;
77 begin.enumerator_ =
begin.enumerable_->get_enumerator();
88 end.enumerable_ = enumerable;
89 end.enumerator_ =
end.enumerable_->get_enumerator();
90 end.pos_ = std::numeric_limits<xtd::size>::max();
103 iterator(
const iterator& value) noexcept : enumerable_(value.enumerable_), enumerator_(value.enumerable_->get_enumerator()), pos_ {value.pos_} {reset();}
106 enumerable_ = value.enumerable_;
107 enumerator_ = value.enumerable_->get_enumerator();
133 if (pos_ != std::numeric_limits<xtd::size>::max()) pos_ = enumerator_.move_next() ? pos_ + 1 : std::numeric_limits<xtd::size>::max();
139 auto current = *
this;
147 template<
typename value_t>
154 if (pos_ == std::numeric_limits<xtd::size>::max())
return std::numeric_limits<xtd::size>::max();
167 template<
typename value_t>
168 iterator(
const iterator& base, value_t value) noexcept : enumerable_(base.enumerable_), enumerator_(base.enumerable_->get_enumerator()), pos_ {base.pos_ + value} {reset();}
172 if (pos_ == std::numeric_limits<xtd::size>::max())
return;
173 for (
auto index =
xtd::size {}; index <= pos_; ++index)
174 if (enumerator_.move_next() ==
false) {
175 pos_ = std::numeric_limits<xtd::size>::max();
180 const enumerable_t* enumerable_ =
nullptr;
181 enumerator<type_t> enumerator_;
Represents the iterator of enumarable value type.
Definition enumerable_iterators.h:50
const_reference operator*() const
Returns reference to the current element, or a proxy holding it.
Definition enumerable_iterators.h:119
friend bool operator!=(const iterator &a, const iterator &b) noexcept
Definition enumerable_iterators.h:163
value_type & reference
Represents the reference of the value type.
Definition enumerable_iterators.h:66
iterator operator+(value_t value) const noexcept
Add operator with specified value.
Definition enumerable_iterators.h:148
type_t value_type
Represents the value type.
Definition enumerable_iterators.h:58
std::forward_iterator_tag iterator_category
Represents the iterator category type.
Definition enumerable_iterators.h:56
const_pointer operator->() const
Returns pointer to the current element, or a proxy holding it.
Definition enumerable_iterators.h:125
iterator & operator++() noexcept
Pre increments the underlying iterator.
Definition enumerable_iterators.h:132
const value_type * const_pointer
Represents the const pointer of the value type.
Definition enumerable_iterators.h:64
static iterator end(const enumerable_t *enumerable)
Create end xtd::collections::generic::iterator with specified enumerator.
Definition enumerable_iterators.h:86
iterator()=default
Initializes a new instance of the xtd::collections::generic::iterator class.
const value_type & const_reference
Represents the const reference of the value type.
Definition enumerable_iterators.h:68
value_type * pointer
Represents the pointer of the value type.
Definition enumerable_iterators.h:62
static iterator begin(const enumerable_t *enumerable)
Create begin xtd::collections::generic::iterator with specified enumerator.
Definition enumerable_iterators.h:74
friend bool operator==(const iterator &a, const iterator &b) noexcept
Definition enumerable_iterators.h:160
xtd::ptrdiff difference_type
Represents the value type.
Definition enumerable_iterators.h:60
difference_type operator-(iterator value) const noexcept
Subtract The specified iterator from the current iterator.
Definition enumerable_iterators.h:153
Internal enumarable iterators definition.
Definition enumerable_iterators.h:44
virtual const_iterator cend() const
Returns an iterator to the element following the last element of the enumarable.
Definition enumerable_iterators.h:209
virtual iterator begin()
Returns an iterator to the first element of the enumarable.
Definition enumerable_iterators.h:201
virtual iterator end()
Returns an iterator to the element following the last element of the enumarable.
Definition enumerable_iterators.h:216
virtual const_iterator cbegin() const
Returns an iterator to the first element of the enumarable.
Definition enumerable_iterators.h:205
virtual const_iterator end() const
Returns an iterator to the element following the last element of the enumarable.
Definition enumerable_iterators.h:213
virtual const_iterator begin() const
Returns an iterator to the first element of the enumarable.
Definition enumerable_iterators.h:198
Contains xtd::collections::generic::enumerator <type_t> interface.
size_t size
Represents a size of any object in bytes.
Definition size.h:23
std::ptrdiff_t ptrdiff
Represent the signed integer type of the result of subtracting two pointers.
Definition ptrdiff.h:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10