rippled
Loading...
Searching...
No Matches
include
xrpl
basics
UnorderedContainers.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef RIPPLE_BASICS_UNORDEREDCONTAINERS_H_INCLUDED
21
#define RIPPLE_BASICS_UNORDEREDCONTAINERS_H_INCLUDED
22
23
#include <xrpl/basics/hardened_hash.h>
24
#include <xrpl/basics/partitioned_unordered_map.h>
25
#include <xrpl/beast/hash/hash_append.h>
26
#include <xrpl/beast/hash/uhash.h>
27
#include <xrpl/beast/hash/xxhasher.h>
28
29
#include <
unordered_map
>
30
#include <
unordered_set
>
31
44
namespace
ripple
{
45
46
// hash containers
47
48
template
<
49
class
Key,
50
class
Value,
51
class
Hash =
beast::uhash<>
,
52
class
Pred =
std::equal_to<Key>
,
53
class
Allocator =
std::allocator<std::pair<Key const, Value>
>>
54
using
hash_map
=
std::unordered_map<Key, Value, Hash, Pred, Allocator>
;
55
56
template
<
57
class
Key,
58
class
Value,
59
class
Hash =
beast::uhash<>
,
60
class
Pred =
std::equal_to<Key>
,
61
class
Allocator =
std::allocator<std::pair<Key const, Value>
>>
62
using
hash_multimap
=
63
std::unordered_multimap<Key, Value, Hash, Pred, Allocator>
;
64
65
template
<
66
class
Value,
67
class
Hash =
beast::uhash<>
,
68
class
Pred =
std::equal_to<Value>
,
69
class
Allocator =
std::allocator<Value>
>
70
using
hash_set
=
std::unordered_set<Value, Hash, Pred, Allocator>
;
71
72
template
<
73
class
Value,
74
class
Hash =
beast::uhash<>
,
75
class
Pred =
std::equal_to<Value>
,
76
class
Allocator =
std::allocator<Value>
>
77
using
hash_multiset
=
std::unordered_multiset<Value, Hash, Pred, Allocator>
;
78
79
// hardened_hash containers
80
81
using
strong_hash
=
beast::xxhasher
;
82
83
template
<
84
class
Key,
85
class
Value,
86
class
Hash =
hardened_hash<strong_hash>
,
87
class
Pred =
std::equal_to<Key>
,
88
class
Allocator =
std::allocator<std::pair<Key const, Value>
>>
89
using
hardened_hash_map
=
std::unordered_map<Key, Value, Hash, Pred, Allocator>
;
90
91
template
<
92
class
Key,
93
class
Value,
94
class
Hash =
hardened_hash<strong_hash>
,
95
class
Pred =
std::equal_to<Key>
,
96
class
Allocator =
std::allocator<std::pair<Key const, Value>
>>
97
using
hardened_partitioned_hash_map
=
98
partitioned_unordered_map<Key, Value, Hash, Pred, Allocator>
;
99
100
template
<
101
class
Key,
102
class
Value,
103
class
Hash =
hardened_hash<strong_hash>
,
104
class
Pred =
std::equal_to<Key>
,
105
class
Allocator =
std::allocator<std::pair<Key const, Value>
>>
106
using
hardened_hash_multimap
=
107
std::unordered_multimap<Key, Value, Hash, Pred, Allocator>
;
108
109
template
<
110
class
Value,
111
class
Hash =
hardened_hash<strong_hash>
,
112
class
Pred =
std::equal_to<Value>
,
113
class
Allocator =
std::allocator<Value>
>
114
using
hardened_hash_set
=
std::unordered_set<Value, Hash, Pred, Allocator>
;
115
116
template
<
117
class
Value,
118
class
Hash =
hardened_hash<strong_hash>
,
119
class
Pred =
std::equal_to<Value>
,
120
class
Allocator =
std::allocator<Value>
>
121
using
hardened_hash_multiset
=
122
std::unordered_multiset<Value, Hash, Pred, Allocator>
;
123
124
}
// namespace ripple
125
126
#endif
std::allocator
beast::xxhasher
Definition
xxhasher.h:36
ripple::hardened_hash
Seed functor once per construction.
Definition
hardened_hash.h:93
ripple::partitioned_unordered_map
Definition
partitioned_unordered_map.h:57
std::equal_to
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:25
beast::uhash
Definition
uhash.h:32
unordered_map
std::unordered_multimap
std::unordered_multiset
unordered_set
Generated by
1.9.8