Confluent Sets and Maps
Public Member Functions | Static Public Member Functions | List of all members
confluent::set_provider< T, Compare, Hash, Equal > Class Template Reference

Public Member Functions

 set_provider (const Compare &compare=Compare(), const Hash &hash=Hash(), const Equal &equal=Equal())
 
 set_provider (const set_provider &)=delete
 
const Compare & key_comp () const
 
const Hash & key_hash () const
 
const Equal & key_eq () const
 
size_t size () const
 

Static Public Member Functions

static const std::shared_ptr< set_provider > & default_provider ()
 

Detailed Description

template<class T, class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
class confluent::set_provider< T, Compare, Hash, Equal >

A set_provider provides resources such as nodes and functors to instances of set and map.

If not specified when creating a new set, the created set will use a global instance of the provider, otherwise the specified provider will be used. Binary set operations require both input sets to be using the same provider, if not the result is undefined. New sets that are created as a result of set operations will use the same provider as the parent set(s).

All sets and maps using the same provider will share structurally equal nodes. If an element is inserted in one container and another element that compares equal is inserted in another container using the same provider, it is then undefined which of the elements that will be copy constructed into the shared nodes and later found when looking up elements in the containers.

New providers can be created to make partitions that cannot share nodes or to create containers with stateful functors that cannot be default constructed and therefore prevents default construction of a global provider instance.

A set_provider should be owned by a std::shared_ptr and it is recommended to use the helper function std::make_shared<set_provider<>>() to instantiate new providers.

Constructor & Destructor Documentation

◆ set_provider()

template<class T , class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
confluent::set_provider< T, Compare, Hash, Equal >::set_provider ( const Compare &  compare = Compare(),
const Hash &  hash = Hash(),
const Equal &  equal = Equal() 
)
inline

Constructs a new set_provider.

Parameters
comparecomparison function that defines sort order
hashhash function for computing hash values of elements
equalcomparison function that tests if elements are equal

Member Function Documentation

◆ key_comp()

template<class T , class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
const Compare& confluent::set_provider< T, Compare, Hash, Equal >::key_comp ( ) const
inline

Returns the comparison function that defines sort order.

◆ key_hash()

template<class T , class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
const Hash& confluent::set_provider< T, Compare, Hash, Equal >::key_hash ( ) const
inline

Returns the hash function.

◆ key_eq()

template<class T , class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
const Equal& confluent::set_provider< T, Compare, Hash, Equal >::key_eq ( ) const
inline

Returns the comparison function that tests if elements are equal.

◆ size()

template<class T , class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
size_t confluent::set_provider< T, Compare, Hash, Equal >::size ( ) const
inline

Returns the number of nodes allocated by this provider.

◆ default_provider()

template<class T , class Compare = std::less<T>, class Hash = std::hash<T>, class Equal = std::equal_to<T>>
static const std::shared_ptr<set_provider>& confluent::set_provider< T, Compare, Hash, Equal >::default_provider ( )
inlinestatic

Returns a shared pointer to the default instance.


The documentation for this class was generated from the following file: