cesium-native 0.52.0
Loading...
Searching...
No Matches
TransformIterator.h
1#pragma once
2
3#include <iterator>
4#include <type_traits>
5
6namespace CesiumUtility {
7
12template <typename TTransformFunction, typename TIterator>
14public:
20 typename std::iterator_traits<TIterator>::iterator_category;
21
26 using value_type = typename std::invoke_result_t<
27 TTransformFunction,
28 typename std::iterator_traits<TIterator>::reference>;
29
35 typename std::iterator_traits<TIterator>::difference_type;
36
45 struct pointer {
50
54 value_type* operator->() { return &value; }
55 };
56
65 TransformIterator(TTransformFunction transformFunction, TIterator iterator)
66 : _iterator(iterator), _transformFunction(transformFunction) {}
67
73 return this->_transformFunction(*this->_iterator);
74 }
75
80 pointer operator->() const {
81 return pointer{this->_transformFunction(*this->_iterator)};
82 }
83
88 ++this->_iterator;
89 return *this;
90 }
91
96 TransformIterator temp = *this;
97 ++(*this);
98 return temp;
99 }
100
104 bool operator==(const TransformIterator& rhs) const {
105 return this->_iterator == rhs._iterator;
106 }
107
111 bool operator!=(const TransformIterator& other) const {
112 return this->_iterator != other._iterator;
113 }
114
115private:
116 TIterator _iterator;
117
118 // We could get fancy and use the empty base class optimization to make this
119 // iterator type smaller in the (common) case that the transform function has
120 // zero size. But let's keep it simple and just store it as a field for now.
121 TTransformFunction _transformFunction;
122};
123
124} // namespace CesiumUtility
bool operator==(const TransformIterator &rhs) const
Checks if two iterators are at the same item.
TransformIterator & operator++()
Advances the iterator to the next item (pre-incrementing).
value_type operator*() const
Returns the current item being iterated. This applies the transformation function to the current item...
typename std::invoke_result_t< GetOverlayFunctor, typename std::iterator_traits< std::vector< CesiumUtility::IntrusivePointer< CesiumRasterOverlays::ActivatedRasterOverlay > >::const_iterator >::reference > value_type
TransformIterator(TTransformFunction transformFunction, TIterator iterator)
Creates a new instance.
TransformIterator operator++(int)
Advances the iterator to the next item (post-incrementing).
typename std::iterator_traits< std::vector< CesiumUtility::IntrusivePointer< CesiumRasterOverlays::ActivatedRasterOverlay > >::const_iterator >::difference_type difference_type
bool operator!=(const TransformIterator &other) const
Checks if two iterators are NOT at the same item.
typename std::iterator_traits< std::vector< CesiumUtility::IntrusivePointer< CesiumRasterOverlays::ActivatedRasterOverlay > >::const_iterator >::iterator_category iterator_category
pointer operator->() const
Returns a pointer to the current item being iterated. This applies the transformation function to the...
Utility classes for Cesium.
A pointer to the type being iterated over.
value_type * operator->()
Returns a pointer to the value.
value_type value
The value pointed to by the pointer.