abseil-cpp/absl/container/internal/hash_generator_testing.cc
Go to the documentation of this file.
1 // Copyright 2018 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/container/internal/hash_generator_testing.h"
16 
17 #include <deque>
18 
19 namespace absl {
21 namespace container_internal {
22 namespace hash_internal {
23 namespace {
24 
25 class RandomDeviceSeedSeq {
26  public:
28 
29  template <class Iterator>
31  while (start != end) {
32  *start = gen_();
33  ++start;
34  }
35  }
36 
37  private:
38  std::random_device gen_;
39 };
40 
41 } // namespace
42 
43 std::mt19937_64* GetSharedRng() {
44  static auto* rng = [] {
45  RandomDeviceSeedSeq seed_seq;
46  return new std::mt19937_64(seed_seq);
47  }();
48  return rng;
49 }
50 
52  // NOLINTNEXTLINE(runtime/int)
53  std::uniform_int_distribution<short> chars(0x20, 0x7E);
54  std::string res;
55  res.resize(32);
56  std::generate(res.begin(), res.end(),
57  [&]() { return chars(*GetSharedRng()); });
58  return res;
59 }
60 
62  static auto* arena = new std::deque<std::string>();
63  // NOLINTNEXTLINE(runtime/int)
64  std::uniform_int_distribution<short> chars(0x20, 0x7E);
65  arena->emplace_back();
66  auto& res = arena->back();
67  res.resize(32);
68  std::generate(res.begin(), res.end(),
69  [&]() { return chars(*GetSharedRng()); });
70  return res;
71 }
72 
73 } // namespace hash_internal
74 } // namespace container_internal
76 } // namespace absl
absl::container_internal::hash_internal::GetSharedRng
std::mt19937_64 * GetSharedRng()
Definition: abseil-cpp/absl/container/internal/hash_generator_testing.cc:43
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition: third_party/abseil-cpp/absl/base/config.h:171
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
start
static uint64_t start
Definition: benchmark-pound.c:74
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition: third_party/abseil-cpp/absl/base/config.h:170
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
result_type
const typedef int * result_type
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:4325
absl::container_internal::Generator::operator()
K operator()(int i) const
Definition: abseil-cpp/absl/container/btree_test.h:81
abseil.generate
def generate(args)
Definition: abseil-cpp/absl/abseil.podspec.gen.py:200
gen_
std::random_device gen_
Definition: abseil-cpp/absl/container/internal/hash_generator_testing.cc:38
absl::inlined_vector_internal::Iterator
Pointer< A > Iterator
Definition: abseil-cpp/absl/container/internal/inlined_vector.h:64
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:00