aboutsummaryrefslogtreecommitdiff
path: root/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-09 06:03:12 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-09 06:03:12 +0000
commit87460ad6f67179bae58b90808fa75cee36ff1fdb (patch)
tree2ce94d7f0804ccb77d1fa9b2a1bca00eecdff1e2 /third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h
parenta98bed7c37bbed320b1d4a270bf29fc9a538817c (diff)
parent7563023510bf04108a954596ea9393a4c11ac279 (diff)
downloadwebrtc-android13-frc-extservices-release.tar.gz
Snap for 8558685 from 7563023510bf04108a954596ea9393a4c11ac279 to tm-frc-extservices-releaset_frc_ext_330443000android13-frc-extservices-release
Change-Id: Iee8dd3827a6bd2f3d16f1fc31fee73d728883f14
Diffstat (limited to 'third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h')
-rw-r--r--third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h b/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h
index 6869fe45e8..f1f555a5c1 100644
--- a/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h
+++ b/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h
@@ -21,11 +21,13 @@
#include <stdint.h>
#include <algorithm>
+#include <cassert>
#include <iosfwd>
#include <random>
#include <tuple>
#include <type_traits>
#include <utility>
+#include <vector>
#include "absl/container/internal/hash_policy_testing.h"
#include "absl/memory/memory.h"
@@ -153,6 +155,25 @@ using GeneratedType = decltype(
typename Container::value_type,
typename Container::key_type>::type>&>()());
+// Naive wrapper that performs a linear search of previous values.
+// Beware this is O(SQR), which is reasonable for smaller kMaxValues.
+template <class T, size_t kMaxValues = 64, class E = void>
+struct UniqueGenerator {
+ Generator<T, E> gen;
+ std::vector<T> values;
+
+ T operator()() {
+ assert(values.size() < kMaxValues);
+ for (;;) {
+ T value = gen();
+ if (std::find(values.begin(), values.end(), value) == values.end()) {
+ values.push_back(value);
+ return value;
+ }
+ }
+ }
+};
+
} // namespace hash_internal
} // namespace container_internal
ABSL_NAMESPACE_END