/src/aspell/common/hash-t.hpp
Line | Count | Source (jump to first uncovered line) |
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 | 10.2k | { |
64 | 10.2k | PrimeIndex i = prime_index_; |
65 | 10.2k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; |
66 | 0 | return i; |
67 | 10.2k | } 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 | 39 | { | 64 | 39 | PrimeIndex i = prime_index_; | 65 | 39 | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 39 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int) Line | Count | Source | 63 | 7.43k | { | 64 | 7.43k | PrimeIndex i = prime_index_; | 65 | 7.43k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 7.43k | } |
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 | 1.38k | { | 64 | 1.38k | PrimeIndex i = prime_index_; | 65 | 1.38k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 1.38k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int) Line | Count | Source | 63 | 1.38k | { | 64 | 1.38k | PrimeIndex i = prime_index_; | 65 | 1.38k | while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i; | 66 | 0 | return i; | 67 | 1.38k | } |
|
68 | | |
69 | | template <class P> |
70 | 28.5k | void HashTable<P>::create_table(PrimeIndex i) { |
71 | 28.5k | prime_index_ = i; |
72 | 28.5k | table_size_ = primes[prime_index_]; |
73 | 28.5k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); |
74 | 28.5k | table_end_ = table_ + table_size_; |
75 | 28.5k | *table_end_ = reinterpret_cast<Node *>(table_end_); |
76 | 28.5k | } acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int) Line | Count | Source | 70 | 11.4k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 11.4k | prime_index_ = i; | 72 | 11.4k | table_size_ = primes[prime_index_]; | 73 | 11.4k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 11.4k | table_end_ = table_ + table_size_; | 75 | 11.4k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 11.4k | } |
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int) Line | Count | Source | 70 | 530 | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 530 | prime_index_ = i; | 72 | 530 | table_size_ = primes[prime_index_]; | 73 | 530 | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 530 | table_end_ = table_ + table_size_; | 75 | 530 | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 530 | } |
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 | 82 | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 82 | prime_index_ = i; | 72 | 82 | table_size_ = primes[prime_index_]; | 73 | 82 | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 82 | table_end_ = table_ + table_size_; | 75 | 82 | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 82 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int) Line | Count | Source | 70 | 13.7k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 13.7k | prime_index_ = i; | 72 | 13.7k | table_size_ = primes[prime_index_]; | 73 | 13.7k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 13.7k | table_end_ = table_ + table_size_; | 75 | 13.7k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 13.7k | } |
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 | 1.38k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 1.38k | prime_index_ = i; | 72 | 1.38k | table_size_ = primes[prime_index_]; | 73 | 1.38k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 1.38k | table_end_ = table_ + table_size_; | 75 | 1.38k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 1.38k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int) Line | Count | Source | 70 | 1.38k | void HashTable<P>::create_table(PrimeIndex i) { | 71 | 1.38k | prime_index_ = i; | 72 | 1.38k | table_size_ = primes[prime_index_]; | 73 | 1.38k | table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *))); | 74 | 1.38k | table_end_ = table_ + table_size_; | 75 | 1.38k | *table_end_ = reinterpret_cast<Node *>(table_end_); | 76 | 1.38k | } |
|
77 | | |
78 | | template <class P> |
79 | | void HashTable<P>::init(PrimeIndex i) |
80 | 21.9k | { |
81 | 21.9k | size_ = 0; |
82 | 21.9k | create_table(i); |
83 | 21.9k | node_pool_.add_block(primes[i]); |
84 | 21.9k | } acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int) Line | Count | Source | 80 | 11.2k | { | 81 | 11.2k | size_ = 0; | 82 | 11.2k | create_table(i); | 83 | 11.2k | node_pool_.add_block(primes[i]); | 84 | 11.2k | } |
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int) Line | Count | Source | 80 | 467 | { | 81 | 467 | size_ = 0; | 82 | 467 | create_table(i); | 83 | 467 | node_pool_.add_block(primes[i]); | 84 | 467 | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int) Line | Count | Source | 80 | 39 | { | 81 | 39 | size_ = 0; | 82 | 39 | create_table(i); | 83 | 39 | node_pool_.add_block(primes[i]); | 84 | 39 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int) Line | Count | Source | 80 | 7.43k | { | 81 | 7.43k | size_ = 0; | 82 | 7.43k | create_table(i); | 83 | 7.43k | node_pool_.add_block(primes[i]); | 84 | 7.43k | } |
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 | 1.38k | { | 81 | 1.38k | size_ = 0; | 82 | 1.38k | create_table(i); | 83 | 1.38k | node_pool_.add_block(primes[i]); | 84 | 1.38k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int) Line | Count | Source | 80 | 1.38k | { | 81 | 1.38k | size_ = 0; | 82 | 1.38k | create_table(i); | 83 | 1.38k | node_pool_.add_block(primes[i]); | 84 | 1.38k | } |
|
85 | | |
86 | | template <class P> |
87 | | std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert) |
88 | 805k | { |
89 | 805k | bool have; |
90 | 805k | iterator put_me_here = find_i(parms_.key(to_insert), have); |
91 | 805k | if (have && !parms_.is_multi) |
92 | 291k | return std::pair<iterator,bool>(put_me_here,false); |
93 | 513k | Node * new_node = node_pool_.new_node(); |
94 | 513k | if (new_node == 0) { |
95 | 6.65k | resize_i(prime_index_+1); |
96 | 6.65k | return insert(to_insert); |
97 | 6.65k | } |
98 | 507k | new |
99 | 507k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) |
100 | 507k | Value(to_insert); |
101 | 507k | new_node->next = *put_me_here.n; |
102 | 507k | *put_me_here.n = new_node; |
103 | 507k | ++size_; |
104 | 507k | return std::pair<iterator,bool>(put_me_here,true); |
105 | 513k | } acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&) Line | Count | Source | 88 | 24.8k | { | 89 | 24.8k | bool have; | 90 | 24.8k | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 24.8k | if (have && !parms_.is_multi) | 92 | 5.39k | return std::pair<iterator,bool>(put_me_here,false); | 93 | 19.4k | Node * new_node = node_pool_.new_node(); | 94 | 19.4k | if (new_node == 0) { | 95 | 255 | resize_i(prime_index_+1); | 96 | 255 | return insert(to_insert); | 97 | 255 | } | 98 | 19.1k | new | 99 | 19.1k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 19.1k | Value(to_insert); | 101 | 19.1k | new_node->next = *put_me_here.n; | 102 | 19.1k | *put_me_here.n = new_node; | 103 | 19.1k | ++size_; | 104 | 19.1k | return std::pair<iterator,bool>(put_me_here,true); | 105 | 19.4k | } |
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&) Line | Count | Source | 88 | 12.3k | { | 89 | 12.3k | bool have; | 90 | 12.3k | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 12.3k | if (have && !parms_.is_multi) | 92 | 0 | return std::pair<iterator,bool>(put_me_here,false); | 93 | 12.3k | Node * new_node = node_pool_.new_node(); | 94 | 12.3k | if (new_node == 0) { | 95 | 63 | resize_i(prime_index_+1); | 96 | 63 | return insert(to_insert); | 97 | 63 | } | 98 | 12.3k | new | 99 | 12.3k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 12.3k | Value(to_insert); | 101 | 12.3k | new_node->next = *put_me_here.n; | 102 | 12.3k | *put_me_here.n = new_node; | 103 | 12.3k | ++size_; | 104 | 12.3k | return std::pair<iterator,bool>(put_me_here,true); | 105 | 12.3k | } |
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 | 76.4k | { | 89 | 76.4k | bool have; | 90 | 76.4k | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 76.4k | if (have && !parms_.is_multi) | 92 | 68.8k | return std::pair<iterator,bool>(put_me_here,false); | 93 | 7.57k | Node * new_node = node_pool_.new_node(); | 94 | 7.57k | if (new_node == 0) { | 95 | 43 | resize_i(prime_index_+1); | 96 | 43 | return insert(to_insert); | 97 | 43 | } | 98 | 7.53k | new | 99 | 7.53k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 7.53k | Value(to_insert); | 101 | 7.53k | new_node->next = *put_me_here.n; | 102 | 7.53k | *put_me_here.n = new_node; | 103 | 7.53k | ++size_; | 104 | 7.53k | return std::pair<iterator,bool>(put_me_here,true); | 105 | 7.57k | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&) Line | Count | Source | 88 | 691k | { | 89 | 691k | bool have; | 90 | 691k | iterator put_me_here = find_i(parms_.key(to_insert), have); | 91 | 691k | if (have && !parms_.is_multi) | 92 | 217k | return std::pair<iterator,bool>(put_me_here,false); | 93 | 474k | Node * new_node = node_pool_.new_node(); | 94 | 474k | if (new_node == 0) { | 95 | 6.29k | resize_i(prime_index_+1); | 96 | 6.29k | return insert(to_insert); | 97 | 6.29k | } | 98 | 468k | new | 99 | 468k | (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) | 100 | 468k | Value(to_insert); | 101 | 468k | new_node->next = *put_me_here.n; | 102 | 468k | *put_me_here.n = new_node; | 103 | 468k | ++size_; | 104 | 468k | return std::pair<iterator,bool>(put_me_here,true); | 105 | 474k | } |
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 | 129 | { |
120 | 129 | Size num_erased = 0; |
121 | 129 | bool irrelevant; |
122 | 129 | Node * * first = find_i(k,irrelevant).n; |
123 | 129 | Node * n = *first; |
124 | 171 | while (n != 0 && parms_.equal(parms_.key(n->data), k)) { |
125 | 42 | Node * tmp = n; |
126 | 42 | n->data.~Value(); |
127 | 42 | n = n->next; |
128 | 42 | node_pool_.remove_node(tmp); |
129 | 42 | ++num_erased; |
130 | 42 | } |
131 | 129 | *first = n; |
132 | 129 | size_ -= num_erased; |
133 | 129 | return num_erased; |
134 | 129 | } |
135 | | |
136 | | template <class P> |
137 | | typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have) |
138 | 10.9M | { |
139 | 10.9M | Size pos = parms_.hash(to_find) % table_size_; |
140 | 10.9M | Node * * n = table_ + pos; |
141 | 10.9M | have = false; |
142 | 12.5M | while (true) { |
143 | 12.5M | if (*n == 0) { |
144 | 10.0M | break; |
145 | 10.0M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { |
146 | 855k | have = true; |
147 | 855k | break; |
148 | 855k | } |
149 | 1.59M | n = &(*n)->next; |
150 | 1.59M | } |
151 | 10.9M | return iterator(table_ + pos, n); |
152 | 10.9M | } acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&) Line | Count | Source | 138 | 184k | { | 139 | 184k | Size pos = parms_.hash(to_find) % table_size_; | 140 | 184k | Node * * n = table_ + pos; | 141 | 184k | have = false; | 142 | 268k | while (true) { | 143 | 268k | if (*n == 0) { | 144 | 175k | break; | 145 | 175k | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 9.35k | have = true; | 147 | 9.35k | break; | 148 | 9.35k | } | 149 | 84.1k | n = &(*n)->next; | 150 | 84.1k | } | 151 | 184k | return iterator(table_ + pos, n); | 152 | 184k | } |
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&) Line | Count | Source | 138 | 577k | { | 139 | 577k | Size pos = parms_.hash(to_find) % table_size_; | 140 | 577k | Node * * n = table_ + pos; | 141 | 577k | have = false; | 142 | 899k | while (true) { | 143 | 899k | if (*n == 0) { | 144 | 24.6k | break; | 145 | 875k | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 552k | have = true; | 147 | 552k | break; | 148 | 552k | } | 149 | 322k | n = &(*n)->next; | 150 | 322k | } | 151 | 577k | return iterator(table_ + pos, n); | 152 | 577k | } |
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 | 2.07M | { | 139 | 2.07M | Size pos = parms_.hash(to_find) % table_size_; | 140 | 2.07M | Node * * n = table_ + pos; | 141 | 2.07M | have = false; | 142 | 2.97M | while (true) { | 143 | 2.97M | if (*n == 0) { | 144 | 2.00M | break; | 145 | 2.00M | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 76.3k | have = true; | 147 | 76.3k | break; | 148 | 76.3k | } | 149 | 898k | n = &(*n)->next; | 150 | 898k | } | 151 | 2.07M | return iterator(table_ + pos, n); | 152 | 2.07M | } |
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 | 691k | { | 139 | 691k | Size pos = parms_.hash(to_find) % table_size_; | 140 | 691k | Node * * n = table_ + pos; | 141 | 691k | have = false; | 142 | 986k | while (true) { | 143 | 986k | if (*n == 0) { | 144 | 474k | break; | 145 | 511k | } else if (parms_.equal(parms_.key((*n)->data),to_find)) { | 146 | 217k | have = true; | 147 | 217k | break; | 148 | 217k | } | 149 | 294k | n = &(*n)->next; | 150 | 294k | } | 151 | 691k | return iterator(table_ + pos, n); | 152 | 691k | } |
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 | 7.41M | { | 139 | 7.41M | Size pos = parms_.hash(to_find) % table_size_; | 140 | 7.41M | Node * * n = table_ + pos; | 141 | 7.41M | have = false; | 142 | 7.41M | while (true) { | 143 | 7.41M | if (*n == 0) { | 144 | 7.41M | break; | 145 | 7.41M | } 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 | 7.41M | return iterator(table_ + pos, n); | 152 | 7.41M | } |
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 | 7.41M | { |
158 | 7.41M | c = 0; |
159 | 7.41M | bool have; |
160 | 7.41M | iterator first = find_i(to_find,have); |
161 | 7.41M | if (!have) |
162 | 7.41M | 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 | 7.41M | } |
173 | | |
174 | | template <class P> |
175 | | void HashTable<P>::del() |
176 | 21.8k | { |
177 | 1.68M | for (Node * * i = table_; i != table_end_; ++i) { |
178 | 1.65M | Node * n = *i; |
179 | 2.29M | while (n != 0) { |
180 | 638k | n->data.~Value(); |
181 | 638k | n = n->next; |
182 | 638k | } |
183 | 1.65M | } |
184 | 21.8k | free (table_); |
185 | 21.8k | size_ = 0; |
186 | 21.8k | node_pool_.clear(); |
187 | 21.8k | table_ = 0; |
188 | 21.8k | table_size_ = 0; |
189 | 21.8k | prime_index_ = 0; |
190 | 21.8k | } acommon::HashTable<acommon::StringMap::Parms>::del() Line | Count | Source | 176 | 11.1k | { | 177 | 685k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 674k | Node * n = *i; | 179 | 825k | while (n != 0) { | 180 | 150k | n->data.~Value(); | 181 | 150k | n = n->next; | 182 | 150k | } | 183 | 674k | } | 184 | 11.1k | free (table_); | 185 | 11.1k | size_ = 0; | 186 | 11.1k | node_pool_.clear(); | 187 | 11.1k | table_ = 0; | 188 | 11.1k | table_size_ = 0; | 189 | 11.1k | prime_index_ = 0; | 190 | 11.1k | } |
acommon::HashTable<aspeller::CondsLookupParms>::del() Line | Count | Source | 176 | 467 | { | 177 | 32.2k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 31.8k | Node * n = *i; | 179 | 44.1k | while (n != 0) { | 180 | 12.3k | n->data.~Value(); | 181 | 12.3k | n = n->next; | 182 | 12.3k | } | 183 | 31.8k | } | 184 | 467 | free (table_); | 185 | 467 | size_ = 0; | 186 | 467 | node_pool_.clear(); | 187 | 467 | table_ = 0; | 188 | 467 | table_size_ = 0; | 189 | 467 | prime_index_ = 0; | 190 | 467 | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del() Line | Count | Source | 176 | 39 | { | 177 | 11.6k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 11.5k | Node * n = *i; | 179 | 19.1k | while (n != 0) { | 180 | 7.53k | n->data.~Value(); | 181 | 7.53k | n = n->next; | 182 | 7.53k | } | 183 | 11.5k | } | 184 | 39 | free (table_); | 185 | 39 | size_ = 0; | 186 | 39 | node_pool_.clear(); | 187 | 39 | table_ = 0; | 188 | 39 | table_size_ = 0; | 189 | 39 | prime_index_ = 0; | 190 | 39 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del() Line | Count | Source | 176 | 7.43k | { | 177 | 801k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 793k | Node * n = *i; | 179 | 1.26M | while (n != 0) { | 180 | 468k | n->data.~Value(); | 181 | 468k | n = n->next; | 182 | 468k | } | 183 | 793k | } | 184 | 7.43k | free (table_); | 185 | 7.43k | size_ = 0; | 186 | 7.43k | node_pool_.clear(); | 187 | 7.43k | table_ = 0; | 188 | 7.43k | table_size_ = 0; | 189 | 7.43k | prime_index_ = 0; | 190 | 7.43k | } |
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 | 1.38k | { | 177 | 74.8k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 73.5k | Node * n = *i; | 179 | 73.5k | while (n != 0) { | 180 | 0 | n->data.~Value(); | 181 | 0 | n = n->next; | 182 | 0 | } | 183 | 73.5k | } | 184 | 1.38k | free (table_); | 185 | 1.38k | size_ = 0; | 186 | 1.38k | node_pool_.clear(); | 187 | 1.38k | table_ = 0; | 188 | 1.38k | table_size_ = 0; | 189 | 1.38k | prime_index_ = 0; | 190 | 1.38k | } |
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del() Line | Count | Source | 176 | 1.38k | { | 177 | 74.8k | for (Node * * i = table_; i != table_end_; ++i) { | 178 | 73.5k | Node * n = *i; | 179 | 73.5k | while (n != 0) { | 180 | 0 | n->data.~Value(); | 181 | 0 | n = n->next; | 182 | 0 | } | 183 | 73.5k | } | 184 | 1.38k | free (table_); | 185 | 1.38k | size_ = 0; | 186 | 1.38k | node_pool_.clear(); | 187 | 1.38k | table_ = 0; | 188 | 1.38k | table_size_ = 0; | 189 | 1.38k | prime_index_ = 0; | 190 | 1.38k | } |
|
191 | | |
192 | | template <class P> |
193 | | void HashTable<P>::resize_i(PrimeIndex new_prime_index) |
194 | 6.65k | { |
195 | 6.65k | Node * * old_table = table_; |
196 | 6.65k | Node * * old_end = table_end_; |
197 | 6.65k | Size old_size = table_size_; |
198 | 6.65k | create_table(new_prime_index); |
199 | 479k | for (Node * * i = old_table; i != old_end; ++i) { |
200 | 472k | Node * n = *i; |
201 | 944k | while (n != 0) { |
202 | 472k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); |
203 | 472k | Node * tmp = n; |
204 | 472k | n = n->next; |
205 | 472k | tmp->next = *put_me_here; |
206 | 472k | *put_me_here = tmp; |
207 | 472k | } |
208 | 472k | } |
209 | 6.65k | free(old_table); |
210 | 6.65k | node_pool_.add_block(table_size_ - old_size); |
211 | 6.65k | } acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int) Line | Count | Source | 194 | 255 | { | 195 | 255 | Node * * old_table = table_; | 196 | 255 | Node * * old_end = table_end_; | 197 | 255 | Size old_size = table_size_; | 198 | 255 | create_table(new_prime_index); | 199 | 14.8k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 14.6k | Node * n = *i; | 201 | 29.2k | while (n != 0) { | 202 | 14.6k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 14.6k | Node * tmp = n; | 204 | 14.6k | n = n->next; | 205 | 14.6k | tmp->next = *put_me_here; | 206 | 14.6k | *put_me_here = tmp; | 207 | 14.6k | } | 208 | 14.6k | } | 209 | 255 | free(old_table); | 210 | 255 | node_pool_.add_block(table_size_ - old_size); | 211 | 255 | } |
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int) Line | Count | Source | 194 | 63 | { | 195 | 63 | Node * * old_table = table_; | 196 | 63 | Node * * old_end = table_end_; | 197 | 63 | Size old_size = table_size_; | 198 | 63 | create_table(new_prime_index); | 199 | 7.26k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 7.20k | Node * n = *i; | 201 | 14.4k | while (n != 0) { | 202 | 7.20k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 7.20k | Node * tmp = n; | 204 | 7.20k | n = n->next; | 205 | 7.20k | tmp->next = *put_me_here; | 206 | 7.20k | *put_me_here = tmp; | 207 | 7.20k | } | 208 | 7.20k | } | 209 | 63 | free(old_table); | 210 | 63 | node_pool_.add_block(table_size_ - old_size); | 211 | 63 | } |
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::resize_i(unsigned int) Line | Count | Source | 194 | 43 | { | 195 | 43 | Node * * old_table = table_; | 196 | 43 | Node * * old_end = table_end_; | 197 | 43 | Size old_size = table_size_; | 198 | 43 | create_table(new_prime_index); | 199 | 9.71k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 9.67k | Node * n = *i; | 201 | 19.3k | while (n != 0) { | 202 | 9.67k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 9.67k | Node * tmp = n; | 204 | 9.67k | n = n->next; | 205 | 9.67k | tmp->next = *put_me_here; | 206 | 9.67k | *put_me_here = tmp; | 207 | 9.67k | } | 208 | 9.67k | } | 209 | 43 | free(old_table); | 210 | 43 | node_pool_.add_block(table_size_ - old_size); | 211 | 43 | } |
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int) Line | Count | Source | 194 | 6.29k | { | 195 | 6.29k | Node * * old_table = table_; | 196 | 6.29k | Node * * old_end = table_end_; | 197 | 6.29k | Size old_size = table_size_; | 198 | 6.29k | create_table(new_prime_index); | 199 | 447k | for (Node * * i = old_table; i != old_end; ++i) { | 200 | 440k | Node * n = *i; | 201 | 881k | while (n != 0) { | 202 | 440k | Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_); | 203 | 440k | Node * tmp = n; | 204 | 440k | n = n->next; | 205 | 440k | tmp->next = *put_me_here; | 206 | 440k | *put_me_here = tmp; | 207 | 440k | } | 208 | 440k | } | 209 | 6.29k | free(old_table); | 210 | 6.29k | node_pool_.add_block(table_size_ - old_size); | 211 | 6.29k | } |
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 | 3.32k | { |
216 | 3.32k | init(other.prime_index_); |
217 | 3.32k | size_ = other.size_; |
218 | 3.32k | parms_ = other.parms_; |
219 | 255k | for (unsigned int i = 0; i != other.table_size_; ++i) { |
220 | 388k | for (Node * j = other.table_[i]; j != 0; j = j->next) { |
221 | 136k | Node * n = node_pool_.new_node(); |
222 | 136k | new |
223 | 136k | (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) |
224 | 136k | Value(j->data); |
225 | 136k | n->next = table_[i]; |
226 | 136k | table_[i] = n; |
227 | 136k | } |
228 | 252k | } |
229 | 3.32k | } |
230 | | |
231 | | } |
232 | | |
233 | | |
234 | | #endif |