From: Mike Krinkin Date: Sat, 28 Mar 2015 11:38:07 +0000 (+0300) Subject: Add find_with to unordered intrusive list. X-Git-Tag: v2.1.0~293^2^2~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b092d341974f09deb587e4a59ef279916c29484f;p=libcds.git Add find_with to unordered intrusive list. Ordered intrusive lazy list has find_with method, that allows to lookup items using custom less-like functor, find_with for unordered is similar, but it uses equal_to-like functor. --- diff --git a/cds/intrusive/lazy_list_nogc.h b/cds/intrusive/lazy_list_nogc.h index 255cab87..467d7955 100644 --- a/cds/intrusive/lazy_list_nogc.h +++ b/cds/intrusive/lazy_list_nogc.h @@ -396,7 +396,7 @@ namespace cds { namespace intrusive { } //@endcond - /// Finds the key \p key using \p pred predicate for searching. + /// Finds the key \p key using \p less predicate for searching. Disabled for unordered lists. /** The function is an analog of \ref cds_intrusive_LazyList_nogc_find_func "find(Q&, Func)" but \p pred is used for key comparing. @@ -404,11 +404,24 @@ namespace cds { namespace intrusive { \p pred must imply the same element order as the comparator used for building the list. */ template - typename std::enable_if::type find_with( Q& key, Less pred, Func f ) + typename std::enable_if::type find_with( Q& key, Less less, Func f ) { - CDS_UNUSED( pred ); + CDS_UNUSED( less ); return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less(), f ); } + + /// Finds the key \p key using \p equal predicate for searching. Disabled for ordered lists. + /** + The function is an analog of \ref cds_intrusive_LazyList_nogc_find_func "find(Q&, Func)" + but \p equal is used for key comparing. + \p Equal functor has the interface like \p std::equal_to. + */ + template + typename std::enable_if::type find_with( Q& key, Equal equal, Func f ) + { + CDS_UNUSED( equal ); + return find_at( &m_Head, key, Equal(), f ); + } //@cond template typename std::enable_if::type find_with( Q const& key, Less pred, Func f ) @@ -416,6 +429,13 @@ namespace cds { namespace intrusive { CDS_UNUSED( pred ); return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less(), f ); } + + template + typename std::enable_if::type find_with( Q const& key, Equal equal, Func f ) + { + CDS_UNUSED( equal ); + return find_at( &m_Head, key, Equal(), f ); + } //@endcond /// Finds the key \p key @@ -443,6 +463,19 @@ namespace cds { namespace intrusive { return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less() ); } + /// Finds the key \p key using \p equal predicate for searching. Disabled for ordered lists. + /** + The function is an analog of \ref cds_intrusive_LazyList_nogc_find_val "find(Q const&)" + but \p equal is used for key comparing. + \p Equal functor has the interface like \p std::equal_to. + */ + template + typename std::enable_if::type find_with( Q const& key, Equal equal ) + { + CDS_UNUSED( equal ); + return find_at( &m_Head, key, equal ); + } + /// Clears the list /** The function unlink all items from the list.