307 bool* grow_hint = NULL); |
307 bool* grow_hint = NULL); |
308 |
308 |
309 // Insert which handles a number of cases. |
309 // Insert which handles a number of cases. |
310 template <typename LOOKUP_FUNC, typename VALUE_FUNC, typename CALLBACK_FUNC> |
310 template <typename LOOKUP_FUNC, typename VALUE_FUNC, typename CALLBACK_FUNC> |
311 bool internal_insert(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE_FUNC& value_f, |
311 bool internal_insert(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE_FUNC& value_f, |
312 CALLBACK_FUNC& callback, bool* grow_hint = NULL); |
312 CALLBACK_FUNC& callback, bool* grow_hint = NULL, bool* clean_hint = NULL); |
313 |
313 |
314 // Returns true if an item matching LOOKUP_FUNC is removed. |
314 // Returns true if an item matching LOOKUP_FUNC is removed. |
315 // Calls DELETE_FUNC before destroying the node. |
315 // Calls DELETE_FUNC before destroying the node. |
316 template <typename LOOKUP_FUNC, typename DELETE_FUNC> |
316 template <typename LOOKUP_FUNC, typename DELETE_FUNC> |
317 bool internal_remove(Thread* thread, LOOKUP_FUNC& lookup_f, |
317 bool internal_remove(Thread* thread, LOOKUP_FUNC& lookup_f, |
394 // LOOKUP_FUNC is matching methods, VALUE_FUNC creates value to be inserted |
394 // LOOKUP_FUNC is matching methods, VALUE_FUNC creates value to be inserted |
395 // and CALLBACK_FUNC is called with new or old value. Returns true if the |
395 // and CALLBACK_FUNC is called with new or old value. Returns true if the |
396 // value already exists. |
396 // value already exists. |
397 template <typename LOOKUP_FUNC, typename VALUE_FUNC, typename CALLBACK_FUNC> |
397 template <typename LOOKUP_FUNC, typename VALUE_FUNC, typename CALLBACK_FUNC> |
398 bool get_insert_lazy(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE_FUNC& val_f, |
398 bool get_insert_lazy(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE_FUNC& val_f, |
399 CALLBACK_FUNC& callback_f, bool* grow_hint = NULL) { |
399 CALLBACK_FUNC& callback_f, bool* grow_hint = NULL, bool* clean_hint = NULL) { |
400 return !internal_insert(thread, lookup_f, val_f, callback_f, grow_hint); |
400 return !internal_insert(thread, lookup_f, val_f, callback_f, grow_hint, clean_hint); |
401 } |
401 } |
402 |
402 |
403 // Same without CALLBACK_FUNC. |
403 // Same without CALLBACK_FUNC. |
404 template <typename LOOKUP_FUNC, typename VALUE_FUNC> |
404 template <typename LOOKUP_FUNC, typename VALUE_FUNC> |
405 bool get_insert_lazy(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE_FUNC& val_f, |
405 bool get_insert_lazy(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE_FUNC& val_f, |
434 |
434 |
435 // Returns true true if the item was inserted, duplicates are found with |
435 // Returns true true if the item was inserted, duplicates are found with |
436 // LOOKUP_FUNC. |
436 // LOOKUP_FUNC. |
437 template <typename LOOKUP_FUNC> |
437 template <typename LOOKUP_FUNC> |
438 bool insert(Thread* thread, LOOKUP_FUNC& lookup_f, const VALUE& value, |
438 bool insert(Thread* thread, LOOKUP_FUNC& lookup_f, const VALUE& value, |
439 bool* grow_hint = NULL) { |
439 bool* grow_hint = NULL, bool* clean_hint = NULL) { |
440 LazyValueRetrieve vp(value); |
440 LazyValueRetrieve vp(value); |
441 return internal_insert(thread, lookup_f, vp, noOp, grow_hint); |
441 return internal_insert(thread, lookup_f, vp, noOp, grow_hint, clean_hint); |
442 } |
442 } |
443 |
443 |
444 // This does a fast unsafe insert and can thus only be used when there is no |
444 // This does a fast unsafe insert and can thus only be used when there is no |
445 // risk for a duplicates and no other threads uses this table. |
445 // risk for a duplicates and no other threads uses this table. |
446 bool unsafe_insert(const VALUE& value); |
446 bool unsafe_insert(const VALUE& value); |