Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
core
SkTDynamicHash.h
Go to the documentation of this file.
1
/*
2
* Copyright 2013 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#ifndef SkTDynamicHash_DEFINED
9
#define SkTDynamicHash_DEFINED
10
11
// This is now a simple API wrapper around THashTable<T*>;
12
// please just use SkTHash{Map,Set,Table} directly for new code.
13
#include "
src/core/SkTHash.h
"
14
15
// Traits requires:
16
// static const Key& GetKey(const T&) { ... }
17
// static uint32_t Hash(const Key&) { ... }
18
// We'll look on T for these by default, or you can pass a custom Traits type.
19
template
<
typename
T
,
20
typename
Key
,
21
typename
Traits =
T
>
22
class
SkTDynamicHash
{
23
public
:
24
SkTDynamicHash
() {}
25
26
// It is not safe to call set() or remove() while iterating with either foreach().
27
// If you mutate the entries be very careful not to change the Key.
28
29
template
<
typename
Fn>
// f(T*)
30
void
foreach
(Fn&& fn) {
31
fTable.
foreach
([&](
T
** entry) { fn(*entry); });
32
}
33
template
<
typename
Fn>
// f(T) or f(const T&)
34
void
foreach
(Fn&& fn)
const
{
35
fTable.
foreach
([&](
T
* entry) { fn(*entry); });
36
}
37
38
int
count
()
const
{
return
fTable.
count
(); }
39
40
size_t
approxBytesUsed
()
const
{
return
fTable.
approxBytesUsed
(); }
41
42
T
*
find
(
const
Key
&
key
)
const
{
return
fTable.
findOrNull
(
key
); }
43
44
void
add
(
T
* entry) { fTable.
set
(entry); }
45
void
remove
(
const
Key
&
key
) { fTable.
remove
(
key
); }
46
47
void
rewind
() { fTable.
reset
(); }
48
void
reset
() { fTable.
reset
(); }
49
50
private
:
51
struct
AdaptedTraits {
52
static
const
Key
& GetKey(
T
* entry) {
return
Traits::GetKey(*entry); }
53
static
uint32_t Hash(
const
Key
&
key
) {
return
Traits::Hash(
key
); }
54
};
55
skia_private::THashTable<T*, Key, AdaptedTraits>
fTable;
56
};
57
58
#endif
Key
TArray< uint32_t > Key
Definition
GrStyledShapeTest.cpp:64
SkTHash.h
SkTDynamicHash
Definition
SkTDynamicHash.h:22
SkTDynamicHash::find
T * find(const Key &key) const
Definition
SkTDynamicHash.h:42
SkTDynamicHash::reset
void reset()
Definition
SkTDynamicHash.h:48
SkTDynamicHash::remove
void remove(const Key &key)
Definition
SkTDynamicHash.h:45
SkTDynamicHash::SkTDynamicHash
SkTDynamicHash()
Definition
SkTDynamicHash.h:24
SkTDynamicHash::approxBytesUsed
size_t approxBytesUsed() const
Definition
SkTDynamicHash.h:40
SkTDynamicHash::rewind
void rewind()
Definition
SkTDynamicHash.h:47
SkTDynamicHash::count
int count() const
Definition
SkTDynamicHash.h:38
SkTDynamicHash::add
void add(T *entry)
Definition
SkTDynamicHash.h:44
skia_private::TArray
Definition
SkTArray.h:40
skia_private::THashTable
Definition
SkTHash.h:32
skia_private::THashTable::remove
void remove(const K &key)
Definition
SkTHash.h:146
skia_private::THashTable::count
int count() const
Definition
SkTHash.h:67
skia_private::THashTable::set
T * set(T val)
Definition
SkTHash.h:88
skia_private::THashTable::foreach
void foreach(Fn &&fn)
Definition
SkTHash.h:173
skia_private::THashTable::findOrNull
T findOrNull(const K &key) const
Definition
SkTHash.h:115
skia_private::THashTable::reset
void reset()
Definition
SkTHash.h:64
skia_private::THashTable::approxBytesUsed
size_t approxBytesUsed() const
Definition
SkTHash.h:74
key
int key
Definition
keyboard_key_handler_unittests.cc:114
T
#define T
Definition
precompiler.cc:65
Generated on Fri Apr 26 2024 06:16:49 for Flutter Engine by
1.9.8