Home | Libraries | People | FAQ | More |
This section refers to element iteration over interval containers. Element iterators are available as associated types on interval sets and interval maps.
Variant |
Associated element iterator type for interval container |
---|---|
forward |
|
const forward |
|
reverse |
|
const reverse |
|
There are also associated iterators types T::iterator
,
T::const_iterator
, T::reverse_iterator
and T::reverse_const_iterator
on interval containers.
These are segment iterators.
Segment iterators are "first citizen iterators". Iteration over
segments is fast, compared to an iteration over elements, particularly if
intervals are large. But if we want to view our interval containers as containers
of elements that are usable with std::algoritms, we need to iterate over
elements.
Iteration over elements . . .
domain_types
On the other hand, sometimes iteration over interval containers on the element
level might be desired, if you have some interface that works for std::SortedAssociativeContainers
of elements and you need to quickly use it with an interval container. Accepting
the poorer performance might be less bothersome at times than adjusting your
whole interface for segment iteration.
Caution | |
---|---|
So we advice you to choose element iteration over interval containers judiciously. Do not use element iteration by default or habitual. Always try to achieve results using member functions, global functions or operators (preferably inplace versions) or iteration over segments first. |
Synopsis Complexities |
interval |
interval |
---|---|---|
|
O(1) |
O(1) |
|
O(1) |
O(1) |
|
O(1) |
O(1) |
|
O(1) |
O(1) |
Element iteration |
Description |
---|---|
T::element_iterator T::elements_begin() T::element_const_iterator T::elements_begin()const
|
Returns an element iterator to the first element of the container. |
T::element_iterator T::elements_end() T::element_const_iterator T::elements_end()const
|
Returns an element iterator to a position |
T::element_reverse_iterator T::elements_rbegin() T::element_const_reverse_iterator T::elements_rbegin()const
|
Returns a reverse element iterator to the last element of the container. |
T::element_reverse_iterator T::elements_rend() T::element_const_reverse_iterator T::elements_rend()const
|
Returns a reverse element iterator to a position |
See also . . .
Back to section . . .