Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
public:
#ifdef CDS_DOXYGEN_INVOKED
- typedef Key key_type ; ///< Key type
- typedef Value mapped_type ; ///< Type of value stored in the list
- typedef std::pair<key_type const, mapped_type> value_type ; ///< key/value pair stored in the list
+ typedef Key key_type; ///< Key type
+ typedef Value mapped_type; ///< Type of value stored in the list
+ typedef std::pair<key_type const, mapped_type> value_type; ///< key/value pair stored in the list
#else
typedef typename maker::key_type key_type;
typedef typename maker::mapped_type mapped_type;
typedef typename maker::value_type value_type;
#endif
-
+ typedef Traits traits; ///< List traits
typedef typename base_class::gc gc; ///< Garbage collector used
typedef typename base_class::back_off back_off; ///< Back-off strategy used
typedef typename maker::data_allocator_type allocator_type; ///< Allocator type used for allocate/deallocate data
/// Guarded pointer
typedef typename base_class::guarded_ptr guarded_ptr;
+ //@cond
+ // Rebind traits (split-list support)
+ template <typename... Options>
+ struct rebind_traits {
+ typedef IterableKVList<
+ gc
+ , key_type, mapped_type
+ , typename cds::opt::make_options< traits, Options...>::type
+ > type;
+ };
+
+ // Stat selector
+ template <typename Stat>
+ using select_stat_wrapper = typename base_class::template select_stat_wrapper< Stat >;
+ //@endcond
+
protected:
//@cond
typedef typename base_class::head_type head_type;
@note The function is supported only if \ref mapped_type is default constructible
*/
template <typename K>
-#ifdef CDS_DOXYGEN_INVOKED
- bool
-#else
- typename std::enable_if<
- std::is_same<K, K>::value && std::is_default_constructible< mapped_type >::value,
- bool
- >::type
-#endif
- insert( K const& key )
+ bool insert( K&& key )
{
- return base_class::emplace( key, mapped_type());
+ return base_class::emplace( key_type( std::forward<K>( key )), mapped_type());
}
/// Inserts new node with a key and a value
Returns \p true if inserting successful, \p false otherwise.
*/
template <typename K, typename V>
- bool insert( K const& key, V const& val )
+ bool insert( K&& key, V&& val )
{
- return base_class::emplace( key, val );
+ return base_class::emplace( key_type( std::forward<K>( key )), mapped_type( std::forward<V>( val )));
}
/// Inserts new node and initialize it by a functor
@note The function is supported only if \ref mapped_type is default constructible
*/
template <typename K, typename Func>
-#ifdef CDS_DOXYGEN_INVOKED
- bool
-#else
- typename std::enable_if<
- std::is_same<K, K>::value && std::is_default_constructible< mapped_type >::value,
- bool
- >::type
-#endif
- insert_with( K const& key, Func func )
+ bool insert_with( K&& key, Func func )
{
- return base_class::insert( value_type( key, mapped_type()), func );
+ return base_class::insert( value_type( key_type( std::forward<K>( key )), mapped_type()), func );
}
/// Updates data by \p key
The functor may change non-key fields of \p val; however, \p func must guarantee
that during changing no any other modifications could be made on this item by concurrent threads.
- Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
+ @return <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
\p second is true if new item has been added or \p false if the item with such \p key
already exists.
@note The function is supported only if \ref mapped_type is default constructible
*/
template <typename K, typename Func>
-#ifdef CDS_DOXYGEN_INVOKED
- std::pair<bool, bool>
-#else
- typename std::enable_if<
- std::is_same<K, K>::value && std::is_default_constructible< mapped_type >::value,
- std::pair<bool, bool>
- >::type
-#endif
- update( K const& key, Func f, bool bAllowInsert = true )
+ std::pair<bool, bool> update( K&& key, Func f, bool bAllowInsert = true )
{
- return base_class::update( value_type( key, mapped_type()), f, bAllowInsert );
+ return base_class::update( value_type( key_type( std::forward<K>( key )), mapped_type()), f, bAllowInsert );
}
/// Insert or update
template <typename Q, typename V >
std::pair<bool, bool> upsert( Q&& key, V&& val, bool bInsert = true )
{
- return base_class::upsert( value_type( std::forward<Q>( key ), std::forward<V>( val )), bInsert );
+ return base_class::upsert( value_type( key_type( std::forward<Q>( key )), mapped_type( std::forward<V>( val ))), bInsert );
}
/// Inserts a new node using move semantics
template <typename K, typename... Args>
bool emplace( K&& key, Args&&... args )
{
- return base_class::emplace( std::forward<K>( key ), std::forward<Args>( args )... );
+ return base_class::emplace( key_type( std::forward<K>( key )), mapped_type( std::forward<Args>( args )... ));
}
/// Deletes \p key from the list
// Split-list support
template <typename K>
- bool insert_at( head_type& refHead, const K& key )
+ bool insert_at( head_type& refHead, K&& key )
{
- return base_class::insert_at( refHead, value_type( key, mapped_type() ));
+ return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type() ));
}
template <typename K, typename V>
- bool insert_at( head_type& refHead, const K& key, const V& val )
+ bool insert_at( head_type& refHead, K&& key, V&& val )
{
- return base_class::insert_at( refHead, value_type( key, val ));
+ return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), std::forward<V>( val )));
}
template <typename K, typename Func>
- bool insert_with_at( head_type& refHead, const K& key, Func f )
+ bool insert_with_at( head_type& refHead, K&& key, Func f )
{
- return base_class::insert_at( refHead, value_type( key, mapped_type()), f );
+ return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type()), f );
}
template <typename K, typename... Args>
}
template <typename K, typename Func>
- std::pair<bool, bool> update_at( head_type& refHead, const K& key, Func f, bool bAllowInsert )
+ std::pair<bool, bool> update_at( head_type& refHead, K&& key, Func f, bool bAllowInsert )
{
- return base_class::update_at( refHead, value_type( key, mapped_type()), f, bAllowInsert );
+ return base_class::update_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type()), f, bAllowInsert );
}
template <typename K, typename Compare>
return base_class::erase_at( refHead, key, cmp, f );
}
template <typename K, typename Compare>
- bool extract_at( head_type& refHead, typename guarded_ptr::native_guard& guard, K const& key, Compare cmp )
+ guarded_ptr extract_at( head_type& refHead, K const& key, Compare cmp )
{
- return base_class::extract_at( refHead, guard, key, cmp );
+ return base_class::extract_at( refHead, key, cmp );
}
template <typename K, typename Compare>
}
template <typename K, typename Compare>
- bool get_at( head_type& refHead, typename guarded_ptr::native_guard& guard, K const& key, Compare cmp )
+ guarded_ptr get_at( head_type& refHead, K const& key, Compare cmp )
{
- return base_class::get_at( refHead, guard, key, cmp );
+ return base_class::get_at( refHead, key, cmp );
}
//@endcond