/src/aspell/common/hash-t.hpp
Line | Count | Source |
1 | | // Copyright (c) 2001,2011 |
2 | | // Kevin Atkinson |
3 | | // |
4 | | // Permission to use, copy, modify, distribute and sell this software |
5 | | // and its documentation for any purpose is hereby granted without fee, |
6 | | // provided that the above copyright notice appear in all copies and |
7 | | // that both that copyright notice and this permission notice appear |
8 | | // in supporting documentation. Silicon Graphics makes no |
9 | | // representations about the suitability of this software for any |
10 | | // purpose. It is provided "as is" without express or implied warranty. |
11 | | |
12 | | // prime list taken from SGI STL with the following copyright |
13 | | |
14 | | /* |
15 | | * Copyright (c) 1996-1998 |
16 | | * Silicon Graphics Computer Systems, Inc. |
17 | | * |
18 | | * Permission to use, copy, modify, distribute and sell this software |
19 | | * and its documentation for any purpose is hereby granted without fee, |
20 | | * provided that the above copyright notice appear in all copies and |
21 | | * that both that copyright notice and this permission notice appear |
22 | | * in supporting documentation. Silicon Graphics makes no |
23 | | * representations about the suitability of this software for any |
24 | | * purpose. It is provided "as is" without express or implied warranty. |
25 | | * |
26 | | * |
27 | | * Copyright (c) 1994 |
28 | | * Hewlett-Packard Company |
29 | | * |
30 | | * Permission to use, copy, modify, distribute and sell this software |
31 | | * and its documentation for any purpose is hereby granted without fee, |
32 | | * provided that the above copyright notice appear in all copies and |
33 | | * that both that copyright notice and this permission notice appear |
34 | | * in supporting documentation. Hewlett-Packard Company makes no |
35 | | * representations about the suitability of this software for any |
36 | | * purpose. It is provided "as is" without express or implied warranty. |
37 | | * |
38 | | */ |
39 | | |
40 | | #ifndef autil__hash_t_hh |
41 | | #define autil__hash_t_hh |
42 | | |
43 | | #include <cstdlib> |
44 | | #include <new> |
45 | | |
46 | | #include "hash.hpp" |
47 | | #include "block_slist-t.hpp" |
48 | | |
49 | | namespace acommon { |
50 | | |
51 | | static const unsigned int primes[] = |
52 | | { |
53 | | 53, 97, 193, 389, 769, |
54 | | 1543, 3079, 6151, 12289, 24593, |
55 | | 49157, 98317, 196613, 393241, 786433, |
56 | | 1572869, 3145739, 6291469, 12582917, 25165843, |
57 | | 50331653, 100663319, 201326611, 402653189, 805306457, |
58 | | static_cast<unsigned int>(-1) |
59 | | }; |
60 | | |
61 | | template <class P> |
62 | | typename HashTable<P>::PrimeIndex HashTable<P>::next_largest(Size s) |
63 | 25.9k | { |
64 | 25.9k | PrimeIndex i = prime_index_; |
65 | 25.9k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; |
66 | 0 | return i; |
67 | 25.9k | } acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::next_largest(unsigned int) Line | Count | Source | 63 | 436 | { | 64 | 436 | PrimeIndex i = prime_index_; | 65 | 436 | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 436 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int) Line | Count | Source | 63 | 20.5k | { | 64 | 20.5k | PrimeIndex i = prime_index_; | 65 | 20.5k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 20.5k | } |
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::next_largest(unsigned int) Line | Count | Source | 63 | 2.45k | { | 64 | 2.45k | PrimeIndex i = prime_index_; | 65 | 2.45k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 2.45k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int) Line | Count | Source | 63 | 2.45k | { | 64 | 2.45k | PrimeIndex i = prime_index_; | 65 | 2.45k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 2.45k | } |
|
68 | | |
69 | | template <class P> |
70 | 94.8k | void HashTable<P>::create_table(PrimeIndex i) { |
71 | 94.8k | prime_index_ = i; |
72 | 94.8k | table_size_ = primes[prime_index_]; |
73 | 94.8k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); |
74 | 94.8k | table_end_ = table_ + table_size_; |
75 | 94.8k | *table_end_ = reinterpret_cast<Node *>(table_end_); |
76 | 94.8k | } acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int) Line | Count | Source | 70 | 54.0k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 54.0k | prime_index_ = i; | 72 | 54.0k | table_size_ = primes[prime_index_]; | 73 | 54.0k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 54.0k | table_end_ = table_ + table_size_; | 75 | 54.0k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 54.0k | } |
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int) Line | Count | Source | 70 | 892 | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 892 | prime_index_ = i; | 72 | 892 | table_size_ = primes[prime_index_]; | 73 | 892 | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 892 | table_end_ = table_ + table_size_; | 75 | 892 | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 892 | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::create_table(unsigned int) Line | Count | Source | 70 | 436 | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 436 | prime_index_ = i; | 72 | 436 | table_size_ = primes[prime_index_]; | 73 | 436 | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 436 | table_end_ = table_ + table_size_; | 75 | 436 | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 436 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int) Line | Count | Source | 70 | 34.5k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 34.5k | prime_index_ = i; | 72 | 34.5k | table_size_ = primes[prime_index_]; | 73 | 34.5k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 34.5k | table_end_ = table_ + table_size_; | 75 | 34.5k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 34.5k | } |
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::create_table(unsigned int) Line | Count | Source | 70 | 2.45k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 2.45k | prime_index_ = i; | 72 | 2.45k | table_size_ = primes[prime_index_]; | 73 | 2.45k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 2.45k | table_end_ = table_ + table_size_; | 75 | 2.45k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 2.45k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int) Line | Count | Source | 70 | 2.45k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 2.45k | prime_index_ = i; | 72 | 2.45k | table_size_ = primes[prime_index_]; | 73 | 2.45k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 2.45k | table_end_ = table_ + table_size_; | 75 | 2.45k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 2.45k | } |
|
77 | | |
78 | | template <class P> |
79 | | void HashTable<P>::init(PrimeIndex i) |
80 | 80.3k | { |
81 | 80.3k | size_ = 0; |
82 | 80.3k | create_table(i); |
83 | 80.3k | node_pool_.add_block(primes[i]); |
84 | 80.3k | } acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int) Line | Count | Source | 80 | 53.5k | { | 81 | 53.5k | size_ = 0; | 82 | 53.5k | create_table(i); | 83 | 53.5k | node_pool_.add_block(primes[i]); | 84 | 53.5k | } |
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int) Line | Count | Source | 80 | 817 | { | 81 | 817 | size_ = 0; | 82 | 817 | create_table(i); | 83 | 817 | node_pool_.add_block(primes[i]); | 84 | 817 | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int) Line | Count | Source | 80 | 436 | { | 81 | 436 | size_ = 0; | 82 | 436 | create_table(i); | 83 | 436 | node_pool_.add_block(primes[i]); | 84 | 436 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int) Line | Count | Source | 80 | 20.5k | { | 81 | 20.5k | size_ = 0; | 82 | 20.5k | create_table(i); | 83 | 20.5k | node_pool_.add_block(primes[i]); | 84 | 20.5k | } |
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int) Line | Count | Source | 80 | 2.45k | { | 81 | 2.45k | size_ = 0; | 82 | 2.45k | create_table(i); | 83 | 2.45k | node_pool_.add_block(primes[i]); | 84 | 2.45k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int) Line | Count | Source | 80 | 2.45k | { | 81 | 2.45k | size_ = 0; | 82 | 2.45k | create_table(i); | 83 | 2.45k | node_pool_.add_block(primes[i]); | 84 | 2.45k | } |
|
85 | | |
86 | | template <class P> |
87 | | std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert) |
88 | 1.62M | { |
89 | 1.62M | bool have; |
90 | 1.62M | iterator put_me_here = find_i(parms_.key(to_insert), have); |
91 | 1.62M | if (have && !parms_.is_multi) |
92 | 408k | return std::pair<iterator,bool>(put_me_here,false); |
93 | 1.21M | Node * new_node = node_pool_.new_node(); |
94 | 1.21M | if (new_node == 0) { |
95 | 14.5k | resize_i(prime_index_+1); |
96 | 14.5k | return insert(to_insert); |
97 | 14.5k | } |
98 | 1.20M | new |
99 | 1.20M | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) |
100 | 1.20M | Value(to_insert); |
101 | 1.20M | new_node->next = *put_me_here.n; |
102 | 1.20M | *put_me_here.n = new_node; |
103 | 1.20M | ++size_; |
104 | 1.20M | return std::pair<iterator,bool>(put_me_here,true); |
105 | 1.21M | } acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&) Line | Count | Source | 88 | 52.1k | { | 89 | 52.1k | bool have; | 90 | 52.1k | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 52.1k | if (have && !parms_.is_multi) | 92 | 16.5k | return std::pair<iterator,bool>(put_me_here,false); | 93 | 35.5k | Node * new_node = node_pool_.new_node(); | 94 | 35.5k | if (new_node == 0) { | 95 | 444 | resize_i(prime_index_+1); | 96 | 444 | return insert(to_insert); | 97 | 444 | } | 98 | 35.1k | new | 99 | 35.1k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 35.1k | Value(to_insert); | 101 | 35.1k | new_node->next = *put_me_here.n; | 102 | 35.1k | *put_me_here.n = new_node; | 103 | 35.1k | ++size_; | 104 | 35.1k | return std::pair<iterator,bool>(put_me_here,true); | 105 | 35.5k | } |
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&) Line | Count | Source | 88 | 18.1k | { | 89 | 18.1k | bool have; | 90 | 18.1k | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 18.1k | if (have && !parms_.is_multi) | 92 | 0 | return std::pair<iterator,bool>(put_me_here,false); | 93 | 18.1k | Node * new_node = node_pool_.new_node(); | 94 | 18.1k | if (new_node == 0) { | 95 | 75 | resize_i(prime_index_+1); | 96 | 75 | return insert(to_insert); | 97 | 75 | } | 98 | 18.0k | new | 99 | 18.0k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 18.0k | Value(to_insert); | 101 | 18.0k | new_node->next = *put_me_here.n; | 102 | 18.0k | *put_me_here.n = new_node; | 103 | 18.0k | ++size_; | 104 | 18.0k | return std::pair<iterator,bool>(put_me_here,true); | 105 | 18.1k | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::insert(char const* const&) Line | Count | Source | 88 | 587 | { | 89 | 587 | bool have; | 90 | 587 | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 587 | if (have && !parms_.is_multi) | 92 | 21 | return std::pair<iterator,bool>(put_me_here,false); | 93 | 566 | Node * new_node = node_pool_.new_node(); | 94 | 566 | if (new_node == 0) { | 95 | 0 | resize_i(prime_index_+1); | 96 | 0 | return insert(to_insert); | 97 | 0 | } | 98 | 566 | new | 99 | 566 | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 566 | Value(to_insert); | 101 | 566 | new_node->next = *put_me_here.n; | 102 | 566 | *put_me_here.n = new_node; | 103 | 566 | ++size_; | 104 | 566 | return std::pair<iterator,bool>(put_me_here,true); | 105 | 566 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&) Line | Count | Source | 88 | 1.55M | { | 89 | 1.55M | bool have; | 90 | 1.55M | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 1.55M | if (have && !parms_.is_multi) | 92 | 391k | return std::pair<iterator,bool>(put_me_here,false); | 93 | 1.16M | Node * new_node = node_pool_.new_node(); | 94 | 1.16M | if (new_node == 0) { | 95 | 13.9k | resize_i(prime_index_+1); | 96 | 13.9k | return insert(to_insert); | 97 | 13.9k | } | 98 | 1.15M | new | 99 | 1.15M | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 1.15M | Value(to_insert); | 101 | 1.15M | new_node->next = *put_me_here.n; | 102 | 1.15M | *put_me_here.n = new_node; | 103 | 1.15M | ++size_; | 104 | 1.15M | return std::pair<iterator,bool>(put_me_here,true); | 105 | 1.16M | } |
Unexecuted instantiation: writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::insert(char const* const&) Unexecuted instantiation: acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::insert(std::__1::pair<char const* const, acommon::Vector<char const*> > const&) |
106 | | |
107 | | template <class P> |
108 | | void HashTable<P>::erase(iterator to_erase) |
109 | | { |
110 | | (*to_erase.n)->data.~Value(); |
111 | | Node * tmp = *to_erase.n; |
112 | | *to_erase.n = (*to_erase.n)->next; |
113 | | node_pool_.remove_node(tmp); |
114 | | --size_; |
115 | | } |
116 | | |
117 | | template <class P> |
118 | | typename HashTable<P>::Size HashTable<P>::erase(const Key & k) |
119 | 895 | { |
120 | 895 | Size num_erased = 0; |
121 | 895 | bool irrelevant; |
122 | 895 | Node * * first = find_i(k,irrelevant).n; |
123 | 895 | Node * n = *first; |
124 | 971 | while (n != 0 && parms_.equal(parms_.key(n->data), k)) { |
125 | 76 | Node * tmp = n; |
126 | 76 | n->data.~Value(); |
127 | 76 | n = n->next; |
128 | 76 | node_pool_.remove_node(tmp); |
129 | 76 | ++num_erased; |
130 | 76 | } |
131 | 895 | *first = n; |
132 | 895 | size_ -= num_erased; |
133 | 895 | return num_erased; |
134 | 895 | } |
135 | | |
136 | | template <class P> |
137 | | typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have) |
138 | 47.7M | { |
139 | 47.7M | Size pos = parms_.hash(to_find) % table_size_; |
140 | 47.7M | Node * * n = table_ + pos; |
141 | 47.7M | have = false; |
142 | 49.5M | while (true) { |
143 | 49.5M | if (*n == 0) { |
144 | 46.7M | break; |
145 | 46.7M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { |
146 | 1.08M | have = true; |
147 | 1.08M | break; |
148 | 1.08M | } |
149 | 1.74M | n = &(*n)->next; |
150 | 1.74M | } |
151 | 47.7M | return iterator(table_ + pos, n); |
152 | 47.7M | } acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&) Line | Count | Source | 138 | 374k | { | 139 | 374k | Size pos = parms_.hash(to_find) % table_size_; | 140 | 374k | Node * * n = table_ + pos; | 141 | 374k | have = false; | 142 | 520k | while (true) { | 143 | 520k | if (*n == 0) { | 144 | 350k | break; | 145 | 350k | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 24.7k | have = true; | 147 | 24.7k | break; | 148 | 24.7k | } | 149 | 145k | n = &(*n)->next; | 150 | 145k | } | 151 | 374k | return iterator(table_ + pos, n); | 152 | 374k | } |
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&) Line | Count | Source | 138 | 703k | { | 139 | 703k | Size pos = parms_.hash(to_find) % table_size_; | 140 | 703k | Node * * n = table_ + pos; | 141 | 703k | have = false; | 142 | 1.08M | while (true) { | 143 | 1.08M | if (*n == 0) { | 144 | 36.1k | break; | 145 | 1.05M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 667k | have = true; | 147 | 667k | break; | 148 | 667k | } | 149 | 385k | n = &(*n)->next; | 150 | 385k | } | 151 | 703k | return iterator(table_ + pos, n); | 152 | 703k | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::find_i(char const* const&, bool&) Line | Count | Source | 138 | 22.1M | { | 139 | 22.1M | Size pos = parms_.hash(to_find) % table_size_; | 140 | 22.1M | Node * * n = table_ + pos; | 141 | 22.1M | have = false; | 142 | 22.6M | while (true) { | 143 | 22.6M | if (*n == 0) { | 144 | 22.1M | break; | 145 | 22.1M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 587 | have = true; | 147 | 587 | break; | 148 | 587 | } | 149 | 516k | n = &(*n)->next; | 150 | 516k | } | 151 | 22.1M | return iterator(table_ + pos, n); | 152 | 22.1M | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::find_i(char const* const&, bool&) Line | Count | Source | 138 | 1.55M | { | 139 | 1.55M | Size pos = parms_.hash(to_find) % table_size_; | 140 | 1.55M | Node * * n = table_ + pos; | 141 | 1.55M | have = false; | 142 | 2.25M | while (true) { | 143 | 2.25M | if (*n == 0) { | 144 | 1.16M | break; | 145 | 1.16M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 391k | have = true; | 147 | 391k | break; | 148 | 391k | } | 149 | 699k | n = &(*n)->next; | 150 | 699k | } | 151 | 1.55M | return iterator(table_ + pos, n); | 152 | 1.55M | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::find_i(char const* const&, bool&) Line | Count | Source | 138 | 22.9M | { | 139 | 22.9M | Size pos = parms_.hash(to_find) % table_size_; | 140 | 22.9M | Node * * n = table_ + pos; | 141 | 22.9M | have = false; | 142 | 22.9M | while (true) { | 143 | 22.9M | if (*n == 0) { | 144 | 22.9M | break; | 145 | 22.9M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 0 | have = true; | 147 | 0 | break; | 148 | 0 | } | 149 | 0 | n = &(*n)->next; | 150 | 0 | } | 151 | 22.9M | return iterator(table_ + pos, n); | 152 | 22.9M | } |
Unexecuted instantiation: acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::find_i(char const* const&, bool&) |
153 | | |
154 | | template <class P> |
155 | | std::pair<typename HashTable<P>::iterator, typename HashTable<P>::iterator> |
156 | | HashTable<P>::equal_range_i(const Key & to_find, int & c) |
157 | 22.9M | { |
158 | 22.9M | c = 0; |
159 | 22.9M | bool have; |
160 | 22.9M | iterator first = find_i(to_find,have); |
161 | 22.9M | if (!have) |
162 | 22.9M | return std::pair<iterator,iterator>(end(),end()); |
163 | 0 | iterator last = first; |
164 | 0 | c = 1; |
165 | 0 | ++last; |
166 | 0 | iterator e = end(); |
167 | 0 | while (!(last == e) && parms_.equal(parms_.key(*last), to_find)) { |
168 | 0 | ++c; |
169 | 0 | ++last; |
170 | 0 | } |
171 | 0 | return std::pair<iterator,iterator>(first,last); |
172 | 22.9M | } |
173 | | |
174 | | template <class P> |
175 | | void HashTable<P>::del() |
176 | 80.1k | { |
177 | 5.65M | for (Node * * i = table_; i != table_end_; ++i) { |
178 | 5.57M | Node * n = *i; |
179 | 7.70M | while (n != 0) { |
180 | 2.12M | n->data.~Value(); |
181 | 2.12M | n = n->next; |
182 | 2.12M | } |
183 | 5.57M | } |
184 | 80.1k | free (table_); |
185 | 80.1k | size_ = 0; |
186 | 80.1k | node_pool_.clear(); |
187 | 80.1k | table_ = 0; |
188 | 80.1k | table_size_ = 0; |
189 | 80.1k | prime_index_ = 0; |
190 | 80.1k | } acommon::HashTable<acommon::StringMap::Parms>::del() Line | Count | Source | 176 | 53.3k | { | 177 | 3.45M | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 3.40M | Node * n = *i; | 179 | 4.35M | while (n != 0) { | 180 | 956k | n->data.~Value(); | 181 | 956k | n = n->next; | 182 | 956k | } | 183 | 3.40M | } | 184 | 53.3k | free (table_); | 185 | 53.3k | size_ = 0; | 186 | 53.3k | node_pool_.clear(); | 187 | 53.3k | table_ = 0; | 188 | 53.3k | table_size_ = 0; | 189 | 53.3k | prime_index_ = 0; | 190 | 53.3k | } |
acommon::HashTable<aspeller::CondsLookupParms>::del() Line | Count | Source | 176 | 817 | { | 177 | 52.5k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 51.7k | Node * n = *i; | 179 | 69.7k | while (n != 0) { | 180 | 18.0k | n->data.~Value(); | 181 | 18.0k | n = n->next; | 182 | 18.0k | } | 183 | 51.7k | } | 184 | 817 | free (table_); | 185 | 817 | size_ = 0; | 186 | 817 | node_pool_.clear(); | 187 | 817 | table_ = 0; | 188 | 817 | table_size_ = 0; | 189 | 817 | prime_index_ = 0; | 190 | 817 | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del() Line | Count | Source | 176 | 436 | { | 177 | 23.5k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 23.1k | Node * n = *i; | 179 | 23.6k | while (n != 0) { | 180 | 566 | n->data.~Value(); | 181 | 566 | n = n->next; | 182 | 566 | } | 183 | 23.1k | } | 184 | 436 | free (table_); | 185 | 436 | size_ = 0; | 186 | 436 | node_pool_.clear(); | 187 | 436 | table_ = 0; | 188 | 436 | table_size_ = 0; | 189 | 436 | prime_index_ = 0; | 190 | 436 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del() Line | Count | Source | 176 | 20.5k | { | 177 | 1.86M | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 1.84M | Node * n = *i; | 179 | 2.99M | while (n != 0) { | 180 | 1.15M | n->data.~Value(); | 181 | 1.15M | n = n->next; | 182 | 1.15M | } | 183 | 1.84M | } | 184 | 20.5k | free (table_); | 185 | 20.5k | size_ = 0; | 186 | 20.5k | node_pool_.clear(); | 187 | 20.5k | table_ = 0; | 188 | 20.5k | table_size_ = 0; | 189 | 20.5k | prime_index_ = 0; | 190 | 20.5k | } |
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del() Line | Count | Source | 176 | 2.45k | { | 177 | 132k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 129k | Node * n = *i; | 179 | 129k | while (n != 0) { | 180 | 0 | n->data.~Value(); | 181 | 0 | n = n->next; | 182 | 0 | } | 183 | 129k | } | 184 | 2.45k | free (table_); | 185 | 2.45k | size_ = 0; | 186 | 2.45k | node_pool_.clear(); | 187 | 2.45k | table_ = 0; | 188 | 2.45k | table_size_ = 0; | 189 | 2.45k | prime_index_ = 0; | 190 | 2.45k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del() Line | Count | Source | 176 | 2.45k | { | 177 | 132k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 129k | Node * n = *i; | 179 | 129k | while (n != 0) { | 180 | 0 | n->data.~Value(); | 181 | 0 | n = n->next; | 182 | 0 | } | 183 | 129k | } | 184 | 2.45k | free (table_); | 185 | 2.45k | size_ = 0; | 186 | 2.45k | node_pool_.clear(); | 187 | 2.45k | table_ = 0; | 188 | 2.45k | table_size_ = 0; | 189 | 2.45k | prime_index_ = 0; | 190 | 2.45k | } |
|
191 | | |
192 | | template <class P> |
193 | | void HashTable<P>::resize_i(PrimeIndex new_prime_index) |
194 | 14.5k | { |
195 | 14.5k | Node * * old_table = table_; |
196 | 14.5k | Node * * old_end = table_end_; |
197 | 14.5k | Size old_size = table_size_; |
198 | 14.5k | create_table(new_prime_index); |
199 | 904k | for (Node * * i = old_table; i != old_end; ++i) { |
200 | 889k | Node * n = *i; |
201 | 1.77M | while (n != 0) { |
202 | 889k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); |
203 | 889k | Node * tmp = n; |
204 | 889k | n = n->next; |
205 | 889k | tmp->next = *put_me_here; |
206 | 889k | *put_me_here = tmp; |
207 | 889k | } |
208 | 889k | } |
209 | 14.5k | free(old_table); |
210 | 14.5k | node_pool_.add_block(table_size_ - old_size); |
211 | 14.5k | } acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int) Line | Count | Source | 194 | 444 | { | 195 | 444 | Node * * old_table = table_; | 196 | 444 | Node * * old_end = table_end_; | 197 | 444 | Size old_size = table_size_; | 198 | 444 | create_table(new_prime_index); | 199 | 27.3k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 26.9k | Node * n = *i; | 201 | 53.8k | while (n != 0) { | 202 | 26.9k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 26.9k | Node * tmp = n; | 204 | 26.9k | n = n->next; | 205 | 26.9k | tmp->next = *put_me_here; | 206 | 26.9k | *put_me_here = tmp; | 207 | 26.9k | } | 208 | 26.9k | } | 209 | 444 | free(old_table); | 210 | 444 | node_pool_.add_block(table_size_ - old_size); | 211 | 444 | } |
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int) Line | Count | Source | 194 | 75 | { | 195 | 75 | Node * * old_table = table_; | 196 | 75 | Node * * old_end = table_end_; | 197 | 75 | Size old_size = table_size_; | 198 | 75 | create_table(new_prime_index); | 199 | 8.65k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 8.57k | Node * n = *i; | 201 | 17.1k | while (n != 0) { | 202 | 8.57k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 8.57k | Node * tmp = n; | 204 | 8.57k | n = n->next; | 205 | 8.57k | tmp->next = *put_me_here; | 206 | 8.57k | *put_me_here = tmp; | 207 | 8.57k | } | 208 | 8.57k | } | 209 | 75 | free(old_table); | 210 | 75 | node_pool_.add_block(table_size_ - old_size); | 211 | 75 | } |
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::resize_i(unsigned int) suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int) Line | Count | Source | 194 | 13.9k | { | 195 | 13.9k | Node * * old_table = table_; | 196 | 13.9k | Node * * old_end = table_end_; | 197 | 13.9k | Size old_size = table_size_; | 198 | 13.9k | create_table(new_prime_index); | 199 | 868k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 854k | Node * n = *i; | 201 | 1.70M | while (n != 0) { | 202 | 854k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 854k | Node * tmp = n; | 204 | 854k | n = n->next; | 205 | 854k | tmp->next = *put_me_here; | 206 | 854k | *put_me_here = tmp; | 207 | 854k | } | 208 | 854k | } | 209 | 13.9k | free(old_table); | 210 | 13.9k | node_pool_.add_block(table_size_ - old_size); | 211 | 13.9k | } |
Unexecuted instantiation: writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::resize_i(unsigned int) Unexecuted instantiation: acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::resize_i(unsigned int) |
212 | | |
213 | | template <class P> |
214 | | void HashTable<P>::copy(const HashTable & other) |
215 | 17.2k | { |
216 | 17.2k | init(other.prime_index_); |
217 | 17.2k | size_ = other.size_; |
218 | 17.2k | parms_ = other.parms_; |
219 | 1.48M | for (unsigned int i = 0; i != other.table_size_; ++i) { |
220 | 2.40M | for (Node * j = other.table_[i]; j != 0; j = j->next) { |
221 | 934k | Node * n = node_pool_.new_node(); |
222 | 934k | new |
223 | 934k | (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) |
224 | 934k | Value(j->data); |
225 | 934k | n->next = table_[i]; |
226 | 934k | table_[i] = n; |
227 | 934k | } |
228 | 1.47M | } |
229 | 17.2k | } |
230 | | |
231 | | } |
232 | | |
233 | | |
234 | | #endif |