2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef CDSLIB_CONTAINER_SPLIT_LIST_MAP_H
32 #define CDSLIB_CONTAINER_SPLIT_LIST_MAP_H
34 #include <cds/container/split_list_set.h>
35 #include <cds/details/binary_functor_wrapper.h>
37 namespace cds { namespace container {
39 /// Split-ordered list map
40 /** @ingroup cds_nonintrusive_map
41 \anchor cds_nonintrusive_SplitListMap_hp
43 Hash table implementation based on split-ordered list algorithm discovered by Ori Shalev and Nir Shavit, see
44 - [2003] Ori Shalev, Nir Shavit "Split-Ordered Lists - Lock-free Resizable Hash Tables"
45 - [2008] Nir Shavit "The Art of Multiprocessor Programming"
47 See intrusive::SplitListSet for a brief description of the split-list algorithm.
50 - \p GC - Garbage collector used like \p cds::gc::HP or \p cds::gc::DHP
51 - \p Key - key type of an item stored in the map. It should be copy-constructible
52 - \p Value - value type stored in the map
53 - \p Traits - map traits, default is \p split_list::traits. Instead of declaring \p %split_list::traits -based
54 struct you may apply option-based notation with \p split_list::make_traits metafunction.
56 There are the specializations:
57 - for \ref cds_urcu_desc "RCU" - declared in <tt>cd/container/split_list_map_rcu.h</tt>,
58 see \ref cds_nonintrusive_SplitListMap_rcu "SplitListMap<RCU>".
59 - for \ref cds::gc::nogc declared in <tt>cds/container/split_list_map_nogc.h</tt>,
60 see \ref cds_nonintrusive_SplitListMap_nogc "SplitListMap<gc::nogc>".
64 You should decide what garbage collector you want, and what ordered list you want to use. Split-ordered list
65 is original data structure based on an ordered list. Suppose, you want construct split-list map based on \p gc::HP GC
66 and \p MichaelList as ordered list implementation. Your map should map \p int key to \p std::string value.
67 So, you beginning your code with the following:
69 #include <cds/container/michael_list_hp.h>
70 #include <cds/container/split_list_map.h>
72 namespace cc = cds::container;
74 The inclusion order is important: first, include file for ordered-list implementation (for this example, <tt>cds/container/michael_list_hp.h</tt>),
75 then the header for split-list map <tt>cds/container/split_list_map.h</tt>.
77 Now, you should declare traits for split-list map. The main parts of traits are a hash functor and a comparing functor for the ordered list.
78 We use <tt>std::hash<int></tt> as hash functor and <tt>std::less<int></tt> predicate as comparing functor.
80 The second attention: instead of using \p %MichaelList in \p %SplitListMap traits we use a tag \p cds::contaner::michael_list_tag for the Michael's list.
81 The split-list requires significant support from underlying ordered list class and it is not good idea to dive you
82 into deep implementation details of split-list and ordered list interrelations. The tag paradigm simplifies split-list interface.
85 // SplitListMap traits
86 struct foo_set_traits: public cc::split_list::traits
88 typedef cc::michael_list_tag ordered_list ; // what type of ordered list we want to use
89 typedef std::hash<int> hash ; // hash functor for the key stored in split-list map
91 // Type traits for our MichaelList class
92 struct ordered_list_traits: public cc::michael_list::traits
94 typedef std::less<int> less ; // use our std::less predicate as comparator to order list nodes
99 Now you are ready to declare our map class based on \p %SplitListMap:
101 typedef cc::SplitListMap< cds::gc::DHP, int, std::string, foo_set_traits > int_string_map;
104 You may use the modern option-based declaration instead of classic type-traits-based one:
106 typedef cc::SplitListMap<
107 cs::gc::DHP // GC used
109 ,std::string // value type
110 ,cc::split_list::make_traits< // metafunction to build split-list traits
111 cc::split_list::ordered_list<cc::michael_list_tag> // tag for underlying ordered list implementation
112 ,cc::opt::hash< std::hash<int> > // hash functor
113 ,cc::split_list::ordered_list_traits< // ordered list traits desired
114 cc::michael_list::make_traits< // metafunction to build lazy list traits
115 cc::opt::less< std::less<int> > // less-based compare functor
121 In case of option-based declaration with \p split_list::make_traits metafunction the struct \p foo_set_traits is not required.
123 Now, the map of type \p int_string_map is ready to use in your program.
125 Note that in this example we show only mandatory \p traits parts, optional ones is the default and they are inherited
126 from \p container::split_list::traits. There are many other options for deep tuning of the split-list and
127 ordered-list containers.
133 #ifdef CDS_DOXYGEN_INVOKED
134 class Traits = split_list::traits
140 protected container::SplitListSet<
142 std::pair<Key const, Value>,
143 split_list::details::wrap_map_traits<Key, Value, Traits>
147 typedef container::SplitListSet<
149 std::pair<Key const, Value>,
150 split_list::details::wrap_map_traits<Key, Value, Traits>
155 typedef GC gc; ///< Garbage collector
156 typedef Key key_type; ///< key type
157 typedef Value mapped_type; ///< type of value to be stored in the map
158 typedef Traits traits; ///< Map traits
160 typedef std::pair<key_type const, mapped_type> value_type ; ///< key-value pair type
161 typedef typename base_class::ordered_list ordered_list; ///< Underlying ordered list class
162 typedef typename base_class::key_comparator key_comparator; ///< key compare functor
164 typedef typename base_class::hash hash; ///< Hash functor for \ref key_type
165 typedef typename base_class::item_counter item_counter; ///< Item counter type
166 typedef typename base_class::stat stat; ///< Internal statistics
168 /// Count of hazard pointer required
169 static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount;
173 typedef typename base_class::maker::traits::key_accessor key_accessor;
174 typedef typename base_class::node_type node_type;
179 typedef typename gc::template guarded_ptr< node_type, value_type, details::guarded_ptr_cast_set<node_type, value_type> > guarded_ptr;
182 ///@name Forward iterators (only for debugging purpose)
186 The forward iterator for a split-list has the following features:
187 - it has no post-increment operator
188 - it depends on underlying ordered list iterator
189 - The iterator object cannot be moved across thread boundary because it contains GC's guard that is thread-private GC data.
190 - Iterator ensures thread-safety even if you delete the item that iterator points to. However, in case of concurrent
191 deleting operations it is no guarantee that you iterate all item in the split-list.
192 Moreover, a crash is possible when you try to iterate the next element that has been deleted by concurrent thread.
194 @warning Use this iterator on the concurrent container for debugging purpose only.
196 The iterator interface:
200 // Default constructor
204 iterator( iterator const& src );
206 // Dereference operator
207 value_type * operator ->() const;
209 // Dereference operator
210 value_type& operator *() const;
212 // Preincrement operator
213 iterator& operator ++();
215 // Assignment operator
216 iterator& operator = (iterator const& src);
218 // Equality operators
219 bool operator ==(iterator const& i ) const;
220 bool operator !=(iterator const& i ) const;
224 typedef typename base_class::iterator iterator;
226 /// Const forward iterator
227 typedef typename base_class::const_iterator const_iterator;
229 /// Returns a forward iterator addressing the first element in a map
231 For empty map \code begin() == end() \endcode
235 return base_class::begin();
238 /// Returns an iterator that addresses the location succeeding the last element in a map
240 Do not use the value returned by <tt>end</tt> function to access any item.
241 The returned value can be used only to control reaching the end of the map.
242 For empty map \code begin() == end() \endcode
246 return base_class::end();
249 /// Returns a forward const iterator addressing the first element in a map
250 const_iterator begin() const
252 return base_class::begin();
255 /// Returns a forward const iterator addressing the first element in a map
256 const_iterator cbegin() const
258 return base_class::cbegin();
261 /// Returns an const iterator that addresses the location succeeding the last element in a map
262 const_iterator end() const
264 return base_class::end();
267 /// Returns an const iterator that addresses the location succeeding the last element in a map
268 const_iterator cend() const
270 return base_class::cend();
275 /// Initializes split-ordered map of default capacity
277 The default capacity is defined in bucket table constructor.
278 See \p intrusive::split_list::expandable_bucket_table, \p intrusive::split_list::static_bucket_table
279 which selects by \p intrusive::split_list::traits::dynamic_bucket_table.
285 /// Initializes split-ordered map
287 size_t nItemCount ///< estimated average item count
288 , size_t nLoadFactor = 1 ///< load factor - average item count per bucket. Small integer up to 10, default is 1.
290 : base_class( nItemCount, nLoadFactor )
294 /// Inserts new node with key and default value
296 The function creates a node with \p key and default value, and then inserts the node created into the map.
299 - The \ref key_type should be constructible from value of type \p K.
300 In trivial case, \p K is equal to \ref key_type.
301 - The \ref mapped_type should be default-constructible.
303 Returns \p true if inserting successful, \p false otherwise.
305 template <typename K>
306 bool insert( K&& key )
308 return base_class::emplace( key_type( std::forward<K>( key )), mapped_type());
313 The function creates a node with copy of \p val value
314 and then inserts the node created into the map.
317 - The \ref key_type should be constructible from \p key of type \p K.
318 - The \ref mapped_type should be constructible from \p val of type \p V.
320 Returns \p true if \p val is inserted into the map, \p false otherwise.
322 template <typename K, typename V>
323 bool insert( K&& key, V&& val )
325 return base_class::emplace( key_type( std::forward<K>( key )), mapped_type( std::forward<V>( val )));
328 /// Inserts new node and initialize it by a functor
330 This function inserts new node with key \p key and if inserting is successful then it calls
331 \p func functor with signature
334 void operator()( value_type& item );
338 The argument \p item of user-defined functor \p func is the reference
339 to the map's item inserted:
340 - <tt>item.first</tt> is a const reference to item's key that cannot be changed.
341 - <tt>item.second</tt> is a reference to item's value that may be changed.
343 It should be keep in mind that concurrent modifications of \p <tt>item.second</tt> may be possible.
345 The key_type should be constructible from value of type \p K.
347 The function allows to split creating of new item into two part:
348 - create item from \p key;
349 - insert new item into the map;
350 - if inserting is successful, initialize the value of item by calling \p func functor
352 This can be useful if complete initialization of object of \p mapped_type is heavyweight and
353 it is preferable that the initialization should be completed only if inserting is successful.
355 @warning For \ref cds_nonintrusive_MichaelKVList_gc "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting".
356 \ref cds_nonintrusive_LazyKVList_gc "LazyKVList" provides exclusive access to inserted item and does not require any node-level
359 template <typename K, typename Func>
360 bool insert_with( K&& key, Func func )
362 //TODO: pass arguments by reference (make_pair makes copy)
363 return base_class::insert( std::make_pair( key_type( std::forward<K>( key )), mapped_type()), func );
366 /// For key \p key inserts data of type \p mapped_type created from \p args
368 \p key_type should be constructible from type \p K
370 Returns \p true if inserting successful, \p false otherwise.
372 template <typename K, typename... Args>
373 bool emplace( K&& key, Args&&... args )
375 return base_class::emplace( key_type( std::forward<K>(key)), mapped_type( std::forward<Args>(args)...));
380 The operation performs inserting or changing data with lock-free manner.
382 If \p key is not found in the map, then \p key is inserted iff \p bAllowInsert is \p true.
383 Otherwise, the functor \p func is called with item found.
385 The functor \p func signature depends on ordered list:
387 <b>for \p MichaelKVList, \p LazyKVList</b>
390 void operator()( bool bNew, value_type& item );
394 - \p bNew - \p true if the item has been inserted, \p false otherwise
395 - \p item - the item found or inserted
397 The functor may change any fields of the \p item.second that is \p mapped_type.
399 <b>for \p IterableKVList</b>
401 void func( value_type& val, value_type * old );
404 - \p val - a new data constructed from \p key
405 - \p old - old value that will be retired. If new item has been inserted then \p old is \p nullptr.
407 Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
408 \p second is true if new item has been added or \p false if the item with \p key
409 already is in the map.
411 @warning For \ref cds_nonintrusive_MichaelKVList_gc "MichaelKVList" and \ref cds_nonintrusive_IterableKVList_gc "IterableKVList"
412 as the ordered list see \ref cds_intrusive_item_creating "insert item troubleshooting".
413 \ref cds_nonintrusive_LazyKVList_gc "LazyKVList" provides exclusive access to inserted item and does not require any node-level
416 template <typename K, typename Func>
417 #ifdef CDS_DOXYGE_INVOKED
418 std::pair<bool, bool>
420 typename std::enable_if<
421 std::is_same<K,K>::value && !is_iterable_list< ordered_list >::value,
422 std::pair<bool, bool>
425 update( K&& key, Func func, bool bAllowInsert = true )
427 typedef decltype( std::make_pair( key_type( std::forward<K>( key )), mapped_type())) arg_pair_type;
429 return base_class::update( std::make_pair( key_type( key ), mapped_type()),
430 [&func]( bool bNew, value_type& item, arg_pair_type const& /*val*/ ) {
436 template <typename K, typename Func>
437 #ifdef CDS_DOXYGE_INVOKED
438 std::pair<bool, bool>
440 typename std::enable_if<
441 std::is_same<K, K>::value && is_iterable_list< ordered_list >::value,
442 std::pair<bool, bool>
445 update( K&& key, Func func, bool bAllowInsert = true )
447 return base_class::update( std::make_pair( key_type( std::forward<K>( key )), mapped_type()), func, bAllowInsert );
451 template <typename K, typename Func>
452 CDS_DEPRECATED("ensure() is deprecated, use update()")
453 std::pair<bool, bool> ensure( K const& key, Func func )
455 return update( key, func, true );
459 /// Inserts or updates the node (only for \p IterableKVList)
461 The operation performs inserting or changing data with lock-free manner.
463 If \p key is not found in the map, then \p key is inserted iff \p bAllowInsert is \p true.
464 Otherwise, the current element is changed to \p val, the old element will be retired later.
466 Returns std::pair<bool, bool> where \p first is \p true if operation is successful,
467 \p second is \p true if \p val has been added or \p false if the item with that key
470 template <typename Q, typename V>
471 #ifdef CDS_DOXYGEN_INVOKED
472 std::pair<bool, bool>
474 typename std::enable_if<
475 std::is_same< Q, Q>::value && is_iterable_list< ordered_list >::value,
476 std::pair<bool, bool>
479 upsert( Q&& key, V&& val, bool bAllowInsert = true )
481 return base_class::upsert( std::make_pair( key_type( std::forward<Q>( key )), mapped_type( std::forward<V>( val ))), bAllowInsert );
485 /// Deletes \p key from the map
486 /** \anchor cds_nonintrusive_SplitListMap_erase_val
488 Return \p true if \p key is found and deleted, \p false otherwise
490 template <typename K>
491 bool erase( K const& key )
493 return base_class::erase( key );
496 /// Deletes the item from the map using \p pred predicate for searching
498 The function is an analog of \ref cds_nonintrusive_SplitListMap_erase_val "erase(K const&)"
499 but \p pred is used for key comparing.
500 \p Less functor has the interface like \p std::less.
501 \p Less must imply the same element order as the comparator used for building the map.
503 template <typename K, typename Less>
504 bool erase_with( K const& key, Less pred )
507 return base_class::erase_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
510 /// Deletes \p key from the map
511 /** \anchor cds_nonintrusive_SplitListMap_erase_func
513 The function searches an item with key \p key, calls \p f functor
514 and deletes the item. If \p key is not found, the functor is not called.
516 The functor \p Func interface is:
519 void operator()(value_type& item) { ... }
523 Return \p true if key is found and deleted, \p false otherwise
525 template <typename K, typename Func>
526 bool erase( K const& key, Func f )
528 return base_class::erase( key, f );
531 /// Deletes the item from the map using \p pred predicate for searching
533 The function is an analog of \ref cds_nonintrusive_SplitListMap_erase_func "erase(K const&, Func)"
534 but \p pred is used for key comparing.
535 \p Less functor has the interface like \p std::less.
536 \p Less must imply the same element order as the comparator used for building the map.
538 template <typename K, typename Less, typename Func>
539 bool erase_with( K const& key, Less pred, Func f )
542 return base_class::erase_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>(), f );
545 /// Deletes the item pointed by iterator \p iter (only for \p IterableList based map)
547 Returns \p true if the operation is successful, \p false otherwise.
548 The function can return \p false if the node the iterator points to has already been deleted
551 The function does not invalidate the iterator, it remains valid and can be used for further traversing.
553 @note \p %erase_at() is supported only for \p %SplitListMap based on \p IterableList.
555 #ifdef CDS_DOXYGEN_INVOKED
556 bool erase_at( iterator const& iter )
558 template <typename Iterator>
559 typename std::enable_if< std::is_same<Iterator, iterator>::value && is_iterable_list< ordered_list >::value, bool >::type
560 erase_at( Iterator const& iter )
563 return base_class::erase_at( iter );
566 /// Extracts the item with specified \p key
567 /** \anchor cds_nonintrusive_SplitListMap_hp_extract
568 The function searches an item with key equal to \p key,
569 unlinks it from the map, and returns it as \p guarded_ptr.
570 If \p key is not found the function returns an empty guarded pointer.
572 Note the compare functor should accept a parameter of type \p K that may be not the same as \p value_type.
574 The extracted item is freed automatically when returned \p guarded_ptr object will be destroyed or released.
575 @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
579 typedef cds::container::SplitListMap< your_template_args > splitlist_map;
580 splitlist_map theMap;
583 splitlist_map::guarded_ptr gp(theMap.extract( 5 ));
588 // Destructor of gp releases internal HP guard
592 template <typename K>
593 guarded_ptr extract( K const& key )
595 return base_class::extract_( key );
598 /// Extracts the item using compare functor \p pred
600 The function is an analog of \ref cds_nonintrusive_SplitListMap_hp_extract "extract(K const&)"
601 but \p pred predicate is used for key comparing.
603 \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p K
605 \p pred must imply the same element order as the comparator used for building the map.
607 template <typename K, typename Less>
608 guarded_ptr extract_with( K const& key, Less pred )
611 return base_class::extract_with_( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
614 /// Finds the key \p key
615 /** \anchor cds_nonintrusive_SplitListMap_find_cfunc
617 The function searches the item with key equal to \p key and calls the functor \p f for item found.
618 The interface of \p Func functor is:
621 void operator()( value_type& item );
624 where \p item is the item found.
626 The functor may change \p item.second. Note that the functor is only guarantee
627 that \p item cannot be disposed during functor is executing.
628 The functor does not serialize simultaneous access to the map's \p item. If such access is
629 possible you must provide your own synchronization schema on item level to exclude unsafe item modifications.
631 The function returns \p true if \p key is found, \p false otherwise.
633 template <typename K, typename Func>
634 bool find( K const& key, Func f )
636 return base_class::find( key, [&f](value_type& pair, K const&){ f( pair ); } );
639 /// Finds \p key and returns iterator pointed to the item found (only for \p IterableList)
641 If \p key is not found the function returns \p end().
643 @note This function is supported only for map based on \p IterableList
645 template <typename K>
646 #ifdef CDS_DOXYGEN_INVOKED
649 typename std::enable_if< std::is_same<K,K>::value && is_iterable_list<ordered_list>::value, iterator >::type
653 return base_class::find( key );
656 /// Finds the key \p val using \p pred predicate for searching
658 The function is an analog of \ref cds_nonintrusive_SplitListMap_find_cfunc "find(K const&, Func)"
659 but \p pred is used for key comparing.
660 \p Less functor has the interface like \p std::less.
661 \p Less must imply the same element order as the comparator used for building the map.
663 template <typename K, typename Less, typename Func>
664 bool find_with( K const& key, Less pred, Func f )
667 return base_class::find_with( key,
668 cds::details::predicate_wrapper<value_type, Less, key_accessor>(),
669 [&f](value_type& pair, K const&){ f( pair ); } );
672 /// Finds \p key using \p pred predicate and returns iterator pointed to the item found (only for \p IterableList)
674 The function is an analog of \p find(K&) but \p pred is used for key comparing.
675 \p Less functor has interface like \p std::less.
676 \p pred must imply the same element order as the comparator used for building the map.
678 If \p key is not found the function returns \p end().
680 @note This function is supported only for map based on \p IterableList
682 template <typename K, typename Less>
683 #ifdef CDS_DOXYGEN_INVOKED
686 typename std::enable_if< std::is_same<K, K>::value && is_iterable_list< ordered_list >::value, iterator >::type
688 find_with( K const& key, Less pred )
691 return base_class::find_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
694 /// Checks whether the map contains \p key
696 The function searches the item with key equal to \p key
697 and returns \p true if it is found, and \p false otherwise.
699 Note the hash functor specified for class \p Traits template parameter
700 should accept a parameter of type \p Q that can be not the same as \p value_type.
701 Otherwise, you may use \p contains( Q const&, Less pred ) functions with explicit predicate for key comparing.
703 template <typename K>
704 bool contains( K const& key )
706 return base_class::contains( key );
709 /// Checks whether the map contains \p key using \p pred predicate for searching
711 The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
712 \p Less functor has the interface like \p std::less.
713 \p Less must imply the same element order as the comparator used for building the map.
715 template <typename K, typename Less>
716 bool contains( K const& key, Less pred )
719 return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
722 /// Finds \p key and return the item found
723 /** \anchor cds_nonintrusive_SplitListMap_hp_get
724 The function searches the item with key equal to \p key
725 and returns the item found as a guarded pointer.
726 If \p key is not found the function returns an empty guarded pointer.
728 @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
732 typedef cds::container::SplitListMap< your_template_params > splitlist_map;
733 splitlist_map theMap;
736 splitlist_map::guarded_ptr gp(theMap.get( 5 ));
741 // Destructor of guarded_ptr releases internal HP guard
745 Note the compare functor specified for split-list map
746 should accept a parameter of type \p K that can be not the same as \p value_type.
748 template <typename K>
749 guarded_ptr get( K const& key )
751 return base_class::get_( key );
754 /// Finds \p key and return the item found
756 The function is an analog of \ref cds_nonintrusive_SplitListMap_hp_get "get( K const&)"
757 but \p pred is used for comparing the keys.
759 \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p K
761 \p pred must imply the same element order as the comparator used for building the map.
763 template <typename K, typename Less>
764 guarded_ptr get_with( K const& key, Less pred )
767 return base_class::get_with_( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
770 /// Clears the map (not atomic)
776 /// Checks if the map is empty
778 Emptiness is checked by item counting: if item count is zero then the map is empty.
779 Thus, the correct item counting is an important part of the map implementation.
783 return base_class::empty();
786 /// Returns item count in the map
789 return base_class::size();
792 /// Returns internal statistics
793 stat const& statistics() const
795 return base_class::statistics();
798 /// Returns internal statistics for \p ordered_list
799 typename ordered_list::stat const& list_statistics() const
801 return base_class::list_statistics();
805 }} // namespace cds::container
807 #endif // #ifndef CDSLIB_CONTAINER_SPLIT_LIST_MAP_H