15#include <initializer_list>
25 map.foreach([&n](
int,
double) { n++; });
37 double* found =
map.find(3);
52 for (
int i = 0;
i <
N;
i++) {
77 for (
auto& entry :
map) {
82 const auto& cmap =
map;
88 for (
const auto& entry : cmap) {
93 for (
const auto& [number, timesTwo] : cmap) {
99 for (
int i = 0;
i <
N;
i++) {
104 found = clone.
find(
i);
108 for (
int i =
N;
i < 2*
N;
i++) {
116 for (
int i = 0;
i <
N/2;
i++) {
119 for (
int i = 0;
i <
N;
i++) {
123 found = clone.
find(
i);
139 auto ref = sk_make_sp<SkRefCnt>();
155 REPORTER_ASSERT(r,
map.approxBytesUsed() >= 4 * (
sizeof(
int) +
sizeof(std::string_view)));
157 std::string_view* found =
map.find(1);
185 REPORTER_ASSERT(r,
map.approxBytesUsed() >= (
sizeof(
int) +
sizeof(std::string_view)));
187 std::string_view* found =
map.find(1);
258 for (
auto& entry :
set) {
263 const auto& cset =
set;
264 for (
typename THashSet<T>::Iter iter = cset.begin(); iter != cset.end(); iter++) {
269 for (
auto& entry : cset) {
281 set.remove(
T(
"Hello"));
295 test_hash_set<SkString>(r);
299 test_hash_set<std::string>(r);
303 test_hash_set<std::string_view>(r);
310 CopyCounter() : fID(0), fCounter(nullptr) {}
312 CopyCounter(uint32_t
id, uint32_t* counter) : fID(
id), fCounter(counter) {}
314 CopyCounter(
const CopyCounter& other)
316 , fCounter(other.fCounter) {
321 void operator=(
const CopyCounter& other) {
323 fCounter = other.fCounter;
327 CopyCounter(CopyCounter&& other) { *
this = std::move(other); }
328 void operator=(CopyCounter&& other) {
330 fCounter = other.fCounter;
334 bool operator==(
const CopyCounter& other)
const {
335 return fID == other.fID;
343struct HashCopyCounter {
344 uint32_t operator()(
const CopyCounter&)
const {
354 uint32_t globalCounter = 0;
355 CopyCounter copyCounter1(1, &globalCounter);
356 CopyCounter copyCounter2(2, &globalCounter);
359 set.add(copyCounter1);
363 set.add(copyCounter1);
367 set.add(copyCounter2);
372 set.add(copyCounter1);
373 set.add(copyCounter2);
385 static int GetKey(
const Entry*
e) {
return e->key; }
393 Entry seven = { 7, 24 };
401 auto check_count_cap = [&](
int count,
int cap) {
403 REPORTER_ASSERT(r,
s.approxBytesUsed() == (
sizeof(
int) +
sizeof(uint32_t)) * cap);
407 check_count_cap(0,0);
408 s.add(1); check_count_cap(1,4);
409 s.add(2); check_count_cap(2,4);
410 s.add(3); check_count_cap(3,4);
411 s.add(4); check_count_cap(4,8);
413 s.remove(4); check_count_cap(3,8);
414 s.remove(3); check_count_cap(2,4);
415 s.remove(2); check_count_cap(1,4);
416 s.remove(1); check_count_cap(0,4);
418 s.add(1); check_count_cap(1,4);
419 s.add(2); check_count_cap(2,4);
420 s.add(3); check_count_cap(3,4);
421 s.add(4); check_count_cap(4,8);
425 for (
int i = 0;
i < 10;
i++) {
426 s. add(5); check_count_cap(5,8);
427 s.remove(5); check_count_cap(4,8);
430 s.remove(4); check_count_cap(3,8);
431 for (
int i = 0;
i < 10;
i++) {
432 s. add(4); check_count_cap(4,8);
433 s.remove(4); check_count_cap(3,8);
436 s.remove(3); check_count_cap(2,4);
437 for (
int i = 0;
i < 10;
i++) {
438 s. add(4); check_count_cap(3,4);
439 s.remove(4); check_count_cap(2,4);
442 s.remove(2); check_count_cap(1,4);
443 for (
int i = 0;
i < 10;
i++) {
444 s. add(2); check_count_cap(2,4);
445 s.remove(2); check_count_cap(1,4);
static int count(const THashMap< int, double > &map)
static void test_hash_set(skiatest::Reporter *r)
#define REPORTER_ASSERT(r, cond,...)
bool contains(double x, double y)
V * find(const K &key) const
void remove(const K &key)
typename THashTable< Pair, K >::template Iter< std::pair< K, V > > Iter
const T * find(const T &item) const
bool contains(const T &item) const
typename THashTable< T, T, Traits >::template Iter< T > Iter
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static uint32_t Hash(uint32_t key)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>