Changeset f2ba4c79 in mainline for uspace/lib/cpp/include/internal/hash_table_policies.hpp
- Timestamp:
- 2018-07-05T21:41:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c7d7368
- Parents:
- 4727aacd
- git-author:
- Dzejrou <dzejrou@…> (2018-05-14 22:54:41)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/internal/hash_table_policies.hpp
r4727aacd rf2ba4c79 60 60 auto current = head; 61 61 62 if (!current) 63 return 0; 64 62 65 do 63 66 { … … 246 249 static typename Table::size_type count(const Table& table, const Key& key) 247 250 { 248 auto head = table.table_[ get_bucket_idx_(key)].head;251 auto head = table.table_[table.get_bucket_idx_(key)].head; 249 252 if (!head) 250 253 return 0; … … 299 302 { 300 303 auto idx = table.get_bucket_idx_(key); 301 auto it = table.begin(it); 304 auto head = table.table_[idx].head; 305 auto current = head; 306 table.table_[idx].head = nullptr; 307 308 if (!current) 309 return 0; 310 311 /** 312 * We traverse the list and delete if the keys 313 * equal, if they don't we append the nodes back 314 * to the bucket. 315 */ 302 316 typename Table::size_type res{}; 303 317 304 while (it != table.end(it)) 305 { 306 if (table.keys_equal(key, *it)) 318 do 319 { 320 auto tmp = current; 321 current = current->next; 322 323 if (!table.keys_equal(key, tmp->value)) 324 table.table_[idx].append(tmp); 325 else 307 326 { 308 while (table.keys_equal(key, *it)) 309 { 310 auto node = it.node(); 311 ++it; 312 ++res; 313 314 node.unlink(); 315 delete node; 316 --table.size_; 317 } 318 319 // Elements with equal keys are next to each other. 320 return res; 327 ++res; 328 --table.size_; 329 330 delete tmp; 321 331 } 322 323 ++it; 324 } 332 } 333 while (current != head); 325 334 326 335 return res; … … 407 416 408 417 if (!bucket) 409 return make_pair(table.end(), false);418 table.end(); 410 419 411 420 if (target && table.keys_equal(key, target->value))
Note:
See TracChangeset
for help on using the changeset viewer.
