Support sort option in nonintrusive and kv lists.
[libcds.git] / cds / container / lazy_kvlist_nogc.h
index 7a93b72e1f6ee0c10b8354941ef6f33d2c88e2e7..3f8c67b0740b2b7f8b6c448c590241f9db68d829 100644 (file)
@@ -41,6 +41,7 @@ namespace cds { namespace container {
         //@endcond
 
     public:
+        typedef Traits traits;
         typedef cds::gc::nogc gc; ///< Garbage collector
 #ifdef CDS_DOXYGEN_INVOKED
         typedef Key                                 key_type        ;   ///< Key type
@@ -59,11 +60,11 @@ namespace cds { namespace container {
 
     protected:
         //@cond
-        typedef typename base_class::value_type   node_type;
-        typedef typename maker::cxx_allocator     cxx_allocator;
-        typedef typename maker::node_deallocator  node_deallocator;
-        typedef typename maker::intrusive_traits::compare  intrusive_key_comparator;
-        typedef typename base_class::node_type    head_type;
+        typedef typename base_class::value_type     node_type;
+        typedef typename maker::cxx_allocator       cxx_allocator;
+        typedef typename maker::node_deallocator    node_deallocator;
+        typedef typename base_class::predicate_type intrusive_predicate_type;
+        typedef typename base_class::node_type      head_type;
         //@endcond
 
     protected:
@@ -408,7 +409,7 @@ namespace cds { namespace container {
         template <typename Q>
         iterator find( Q const& key )
         {
-            return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ) );
+            return node_to_iterator( find_at( head(), key, intrusive_predicate_type() ) );
         }
 
         /// Finds the key \p val using \p pred predicate for searching
@@ -418,8 +419,8 @@ namespace cds { namespace container {
             \p Less functor has the interface like \p std::less.
             \p pred must imply the same element order as the comparator used for building the list.
         */
-        template <typename Q, typename Less>
-        iterator find_with( Q const& key, Less pred )
+        template <typename Q, typename Less, bool Sort = traits::sort>
+        typename std::enable_if<Sort, iterator>::type find_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
             return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );