This is an automated email from the ASF dual-hosted git repository. alsay pushed a commit to branch vo_iter_arrow in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
commit 2431e0e8823814bd7c8e08cbf6dab76f08ae3876 Author: AlexanderSaydakov <[email protected]> AuthorDate: Wed Jan 4 15:00:29 2023 -0800 added operator-> to iterator --- sampling/include/var_opt_sketch.hpp | 4 +++- sampling/include/var_opt_sketch_impl.hpp | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sampling/include/var_opt_sketch.hpp b/sampling/include/var_opt_sketch.hpp index 12f96cd..c5cf26c 100644 --- a/sampling/include/var_opt_sketch.hpp +++ b/sampling/include/var_opt_sketch.hpp @@ -348,12 +348,14 @@ 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: + using value_type = std::pair<const T&, const double>; const_iterator(const const_iterator& other); const_iterator& operator++(); const_iterator& operator++(int); bool operator==(const const_iterator& other) const; bool operator!=(const const_iterator& other) const; - const std::pair<const T&, const double> operator*() const; + const value_type operator*() const; + const return_value_holder<value_type> operator->() const; private: friend class var_opt_sketch<T, A>; diff --git a/sampling/include/var_opt_sketch_impl.hpp b/sampling/include/var_opt_sketch_impl.hpp index ef9bbc0..4bf8b22 100644 --- a/sampling/include/var_opt_sketch_impl.hpp +++ b/sampling/include/var_opt_sketch_impl.hpp @@ -1575,14 +1575,19 @@ bool var_opt_sketch<T, A>::const_iterator::operator!=(const const_iterator& othe } template<typename T, typename A> -const std::pair<const T&, const double> var_opt_sketch<T, A>::const_iterator::operator*() const { +auto var_opt_sketch<T, A>::const_iterator::operator*() const -> const value_type { double wt; if (idx_ < sk_->h_) { wt = sk_->weights_[idx_]; } else { wt = r_item_wt_; } - return std::pair<const T&, const double>(sk_->data_[idx_], wt); + return value_type(sk_->data_[idx_], wt); +} + +template<typename T, typename A> +auto var_opt_sketch<T, A>::const_iterator::operator->() const -> const return_value_holder<value_type> { + return **this; } template<typename T, typename A> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
