This is an automated email from the ASF dual-hosted git repository. jmalkin pushed a commit to branch update_iterators in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
commit 2ad16482b33cfeb3dc0d47566961ed5b881ba797 Author: Jon <[email protected]> AuthorDate: Wed Feb 1 09:01:08 2023 -0800 Remove inheritance from std::iterator --- fi/include/reverse_purge_hash_map.hpp | 12 +++++++++--- hll/include/HllArray.hpp | 8 +++++++- hll/include/coupon_iterator.hpp | 8 +++++++- kll/include/kll_sketch.hpp | 7 ++++++- quantiles/include/quantiles_sketch.hpp | 7 ++++++- req/include/req_sketch.hpp | 7 ++++++- sampling/include/var_opt_sketch.hpp | 18 ++++++++++++++---- theta/include/theta_update_sketch_base.hpp | 16 ++++++++++++++-- 8 files changed, 69 insertions(+), 14 deletions(-) diff --git a/fi/include/reverse_purge_hash_map.hpp b/fi/include/reverse_purge_hash_map.hpp index 6e2e53a..9500852 100644 --- a/fi/include/reverse_purge_hash_map.hpp +++ b/fi/include/reverse_purge_hash_map.hpp @@ -91,8 +91,14 @@ private: // This iterator uses strides based on golden ratio to avoid clustering during merge template<typename K, typename V, typename H, typename E, typename A> -class reverse_purge_hash_map<K, V, H, E, A>::iterator: public std::iterator<std::input_iterator_tag, K> { +class reverse_purge_hash_map<K, V, H, E, A>::iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = std::pair<K&, V>; + using difference_type = std::ptrdiff_t; + using pointer = void; + using reference = value_type&; + friend class reverse_purge_hash_map<K, V, H, E, A>; iterator& operator++() { ++count; @@ -107,8 +113,8 @@ public: iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; } bool operator==(const iterator& rhs) const { return count == rhs.count; } bool operator!=(const iterator& rhs) const { return count != rhs.count; } - const std::pair<K&, V> operator*() const { - return std::pair<K&, V>(map->keys_[index], map->values_[index]); + const value_type operator*() const { + return value_type(map->keys_[index], map->values_[index]); } private: static constexpr double GOLDEN_RATIO_RECIPROCAL = 0.6180339887498949; // = (sqrt(5) - 1) / 2 diff --git a/hll/include/HllArray.hpp b/hll/include/HllArray.hpp index 60aee76..b32f7c2 100644 --- a/hll/include/HllArray.hpp +++ b/hll/include/HllArray.hpp @@ -113,8 +113,14 @@ class HllArray : public HllSketchImpl<A> { }; template<typename A> -class HllArray<A>::const_iterator: public std::iterator<std::input_iterator_tag, uint32_t> { +class HllArray<A>::const_iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = uint32_t; + using difference_type = int32_t; + using pointer = uint32_t*; + using reference = uint32_t&; + const_iterator(const uint8_t* array, uint32_t array_slze, uint32_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset, bool all); const_iterator& operator++(); bool operator!=(const const_iterator& other) const; diff --git a/hll/include/coupon_iterator.hpp b/hll/include/coupon_iterator.hpp index 896a2f7..856065b 100644 --- a/hll/include/coupon_iterator.hpp +++ b/hll/include/coupon_iterator.hpp @@ -23,8 +23,14 @@ namespace datasketches { template<typename A> -class coupon_iterator: public std::iterator<std::input_iterator_tag, uint32_t> { +class coupon_iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = uint32_t; + using difference_type = int32_t; + using pointer = uint32_t*; + using reference = uint32_t&; + coupon_iterator(const uint32_t* array, size_t array_slze, size_t index, bool all); coupon_iterator& operator++(); bool operator!=(const coupon_iterator& other) const; diff --git a/kll/include/kll_sketch.hpp b/kll/include/kll_sketch.hpp index 3407afc..0272bf4 100644 --- a/kll/include/kll_sketch.hpp +++ b/kll/include/kll_sketch.hpp @@ -586,9 +586,14 @@ class kll_sketch { }; template<typename T, typename C, typename A> -class kll_sketch<T, C, A>::const_iterator: public std::iterator<std::input_iterator_tag, T> { +class kll_sketch<T, C, A>::const_iterator { public: + using iterator_category = std::input_iterator_tag; using value_type = std::pair<const T&, const uint64_t>; + using difference_type = std::ptrdiff_t; + using pointer = return_value_holder<value_type>; + using reference = value_type&; + friend class kll_sketch<T, C, A>; const_iterator& operator++(); const_iterator& operator++(int); diff --git a/quantiles/include/quantiles_sketch.hpp b/quantiles/include/quantiles_sketch.hpp index 184b784..11377a4 100644 --- a/quantiles/include/quantiles_sketch.hpp +++ b/quantiles/include/quantiles_sketch.hpp @@ -580,9 +580,14 @@ private: template<typename T, typename C, typename A> -class quantiles_sketch<T, C, A>::const_iterator: public std::iterator<std::input_iterator_tag, T> { +class quantiles_sketch<T, C, A>::const_iterator { public: + using iterator_category = std::input_iterator_tag; using value_type = std::pair<const T&, const uint64_t>; + using difference_type = std::ptrdiff_t; + using pointer = return_value_holder<value_type>; + using reference = value_type&; + const_iterator& operator++(); const_iterator& operator++(int); bool operator==(const const_iterator& other) const; diff --git a/req/include/req_sketch.hpp b/req/include/req_sketch.hpp index b6375c5..8beb604 100755 --- a/req/include/req_sketch.hpp +++ b/req/include/req_sketch.hpp @@ -399,9 +399,14 @@ private: }; template<typename T, typename C, typename A> -class req_sketch<T, C, A>::const_iterator: public std::iterator<std::input_iterator_tag, T> { +class req_sketch<T, C, A>::const_iterator { public: + using iterator_category = std::input_iterator_tag; using value_type = std::pair<const T&, const uint64_t>; + using difference_type = std::ptrdiff_t; + using pointer = return_value_holder<value_type>; + using reference = value_type&; + const_iterator& operator++(); const_iterator& operator++(int); bool operator==(const const_iterator& other) const; diff --git a/sampling/include/var_opt_sketch.hpp b/sampling/include/var_opt_sketch.hpp index c5cf26c..8f8b3a7 100644 --- a/sampling/include/var_opt_sketch.hpp +++ b/sampling/include/var_opt_sketch.hpp @@ -346,9 +346,13 @@ class var_opt_sketch { }; template<typename T, typename A> -class var_opt_sketch<T, A>::const_iterator : public std::iterator<std::input_iterator_tag, T> { -public: +class var_opt_sketch<T, A>::const_iterator { + using iterator_category = std::input_iterator_tag; using value_type = std::pair<const T&, const double>; + using difference_type = std::ptrdiff_t; + using pointer = return_value_holder<value_type>; + using reference = value_type&; +public: const_iterator(const const_iterator& other); const_iterator& operator++(); const_iterator& operator++(int); @@ -379,14 +383,20 @@ private: // non-const iterator for internal use template<typename T, typename A> -class var_opt_sketch<T, A>::iterator : public std::iterator<std::input_iterator_tag, T> { +class var_opt_sketch<T, A>::iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = std::pair<T&, double>; + using difference_type = std::ptrdiff_t; + using pointer = return_value_holder<value_type>; + using reference = value_type&; + iterator(const iterator& other); iterator& operator++(); iterator& operator++(int); bool operator==(const iterator& other) const; bool operator!=(const iterator& other) const; - std::pair<T&, double> operator*(); + value_type operator*(); private: friend class var_opt_sketch<T, A>; diff --git a/theta/include/theta_update_sketch_base.hpp b/theta/include/theta_update_sketch_base.hpp index 0be40c0..59228d7 100644 --- a/theta/include/theta_update_sketch_base.hpp +++ b/theta/include/theta_update_sketch_base.hpp @@ -185,8 +185,14 @@ static inline uint64_t compute_hash(const void* data, size_t length, uint64_t se // iterators template<typename Entry, typename ExtractKey> -class theta_iterator: public std::iterator<std::input_iterator_tag, Entry> { +class theta_iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = Entry; + using difference_type = std::ptrdiff_t; + using pointer = Entry*; + using reference = Entry&; + theta_iterator(Entry* entries, uint32_t size, uint32_t index); theta_iterator& operator++(); theta_iterator operator++(int); @@ -201,8 +207,14 @@ private: }; template<typename Entry, typename ExtractKey> -class theta_const_iterator: public std::iterator<std::input_iterator_tag, Entry> { +class theta_const_iterator { public: + using iterator_category = std::input_iterator_tag; + using value_type = const Entry; + using difference_type = std::ptrdiff_t; + using pointer = Entry*; + using reference = Entry&; + theta_const_iterator(const Entry* entries, uint32_t size, uint32_t index); theta_const_iterator& operator++(); theta_const_iterator operator++(int); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
