32 static inline uint32_t
hash(uint32_t x){
return x; }
33 static inline uint32_t
hash(uint64_t x){
return (uint32_t)x; }
34 static inline uint32_t
hash(int32_t x) {
return (uint32_t)x; }
35 static inline uint32_t
hash(int64_t x) {
return (uint32_t)x; }
38 template<
class K>
struct Equal {
bool operator()(
const K& k1,
const K& k2)
const {
return k1 == k2; } };
41 template<
class K>
struct DeepEqual {
bool operator()(
const K* k1,
const K* k2)
const {
return *k1 == *k2; } };
50 static const int primes [
nprimes] = { 31, 73, 151, 313, 643, 1291, 2593, 5233, 10501, 21013, 42073, 84181, 168451, 337219, 674701, 1349473, 2699299, 5398891, 10798093, 21596719, 43193641, 86387383, 172775299, 345550609, 691101253 };
56 template<
class K,
class D,
class H = Hash<K>,
class E = Equal<K> >
85 for (
int i = 1; newsize <=
cap && i <
nprimes; i++)
91 for (
int i = 0; i < old_cap; i++){
92 for (
int j = 0; j < old[i].
size(); j++){
93 _insert(old[i][j].key, old[i][j].data); }}
113 for (
int i = 0; i < ps.
size(); i++)
126 for (
int i = 0; i < ps.
size(); i++)
135 bool peek (
const K& k, D& d)
const {
136 if (
size == 0)
return false;
138 for (
int i = 0; i < ps.
size(); i++)
139 if (
equals(ps[i].key, k)){
145 bool has (
const K& k)
const {
146 if (
size == 0)
return false;
148 for (
int i = 0; i < ps.
size(); i++)
156 assert(
table != NULL);
159 for (; j < ps.
size() && !
equals(ps[j].key, k); j++);
160 assert(j < ps.
size());
177 delete [] other.
table;
void insert(const K &k, const D &d)
Map(const H &h, const E &e)
Map< K, D, H, E > & operator=(Map< K, D, H, E > &)
const vec< Pair > & bucket(int i) const
int32_t index(const K &k) const
bool checkCap(int new_size) const
bool peek(const K &k, D &d) const
void _insert(const K &k, const D &d)
const D & operator[](const K &k) const
bool has(const K &k) const
const T & last(void) const
static const int primes[nprimes]
static uint32_t hash(uint32_t x)
bool operator()(const K *k1, const K *k2) const
uint32_t operator()(const K *k) const
bool operator()(const K &k1, const K &k2) const
uint32_t operator()(const K &k) const