You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/07/01 23:57:08 UTC

[incubator-datasketches-cpp] 01/01: better way to specify ranges

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch msvc_compatibility
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit 592506e31370e14b0ea977560e1e4dcd7a4147a4
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Wed Jul 1 16:56:48 2020 -0700

    better way to specify ranges
---
 theta/include/theta_intersection_impl.hpp | 4 ++--
 theta/include/theta_sketch_impl.hpp       | 2 +-
 theta/include/theta_union_impl.hpp        | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/theta/include/theta_intersection_impl.hpp b/theta/include/theta_intersection_impl.hpp
index 6be6757..d090b3a 100644
--- a/theta/include/theta_intersection_impl.hpp
+++ b/theta/include/theta_intersection_impl.hpp
@@ -100,7 +100,7 @@ void theta_intersection_alloc<A>::update(const theta_sketch_alloc<A>& sketch) {
         lg_size_ = lg_size;
         keys_.resize(1 << lg_size_);
       }
-      std::fill(&keys_[0], &keys_[1 << lg_size_], 0);
+      std::fill(keys_.begin(), keys_.end(), 0);
       for (uint32_t i = 0; i < match_count; i++) {
         update_theta_sketch_alloc<A>::hash_search_or_insert(matched_keys[i], keys_.data(), lg_size_);
       }
@@ -114,7 +114,7 @@ compact_theta_sketch_alloc<A> theta_intersection_alloc<A>::get_result(bool order
   if (!is_valid_) throw std::invalid_argument("calling get_result() before calling update() is undefined");
   vector_u64<A> keys(num_keys_);
   if (num_keys_ > 0) {
-    std::copy_if(&keys_[0], &keys_[1 << lg_size_], &keys[0], [](uint64_t key) { return key != 0; });
+    std::copy_if(keys_.begin(), keys_.end(), keys.begin(), [](uint64_t key) { return key != 0; });
     if (ordered) std::sort(keys.begin(), keys.end());
   }
   return compact_theta_sketch_alloc<A>(is_empty_, theta_, std::move(keys), seed_hash_, ordered);
diff --git a/theta/include/theta_sketch_impl.hpp b/theta/include/theta_sketch_impl.hpp
index 0514884..c099e22 100644
--- a/theta/include/theta_sketch_impl.hpp
+++ b/theta/include/theta_sketch_impl.hpp
@@ -534,7 +534,7 @@ void update_theta_sketch_alloc<A>::resize() {
 template<typename A>
 void update_theta_sketch_alloc<A>::rebuild() {
   const uint32_t pivot = (1 << lg_nom_size_) + keys_.size() - num_keys_;
-  std::nth_element(&keys_[0], &keys_[pivot], &keys_[keys_.size()]);
+  std::nth_element(keys_.begin(), keys_.begin() + pivot, keys_.end());
   this->theta_ = keys_[pivot];
   vector_u64<A> new_keys(keys_.size(), 0);
   num_keys_ = 0;
diff --git a/theta/include/theta_union_impl.hpp b/theta/include/theta_union_impl.hpp
index 5f4d7f9..4d8ebaa 100644
--- a/theta/include/theta_union_impl.hpp
+++ b/theta/include/theta_union_impl.hpp
@@ -61,7 +61,7 @@ compact_theta_sketch_alloc<A> theta_union_alloc<A>::get_result(bool ordered) con
     if (key < theta) keys[num_keys++] = key;
   }
   if (num_keys > nom_num_keys) {
-    std::nth_element(&keys[0], &keys[nom_num_keys], &keys[num_keys]);
+    std::nth_element(keys.begin(), keys.begin() + nom_num_keys, keys.begin() + num_keys);
     theta = keys[nom_num_keys];
     num_keys = nom_num_keys;
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org