Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

immer::set< T, Hash, Equal, MemoryPolicy, B > Class Template Reference

#include <set.hpp>

Public Types

using key_type = T
 
using value_type = T
 
using size_type = detail::hamts::size_t
 
using diference_type = std::ptrdiff_t
 
using hasher = Hash
 
using key_equal = Equal
 
using reference = const T &
 
using const_reference = const T &
 
using iterator = detail::hamts::champ_iterator< T, Hash, Equal, MemoryPolicy, B >
 
using const_iterator = iterator
 
using transient_type = set_transient< T, Hash, Equal, MemoryPolicy, B >
 

Public Member Functions

 set ()=default
 
iterator begin () const
 
iterator end () const
 
size_type size () const
 
size_type count (const T &value) const
 
bool operator== (const set &other) const
 
bool operator!= (const set &other) const
 
set insert (T value) const
 
set erase (const T &value) const
 
transient_type transient () const &
 
transient_type transient () &&
 
const impl_timpl () const
 

Private Types

using impl_t = detail::hamts::champ< T, Hash, Equal, MemoryPolicy, B >
 

Private Member Functions

 set (impl_t impl)
 

Private Attributes

friend transient_type
 
impl_t impl_ = impl_t::empty()
 

Detailed Description

template<typename T, typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
class immer::set< T, Hash, Equal, MemoryPolicy, B >

Immutable set representing an unordered bag of values.

Template Parameters
TThe type of the values to be stored in the container.
HashThe type of a function object capable of hashing values of type T.
EqualThe type of a function object capable of comparing values of type T.
MemoryPolicyMemory management policy. See memory_policy.

This cotainer provides a good trade-off between cache locality, membership checks, update performance and structural sharing. It does so by storing the data in contiguous chunks of :math:2^{B} elements. When storing big objects, the size of these contiguous chunks can become too big, damaging performance. If this is measured to be problematic for a specific use-case, it can be solved by using a immer::box to wrap the type T.

Example .. literalinclude:: ../example/set/intro.cpp :language: c++ :start-after: intro/start :end-before: intro/end

Definition at line 61 of file set.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::const_iterator = iterator

Definition at line 77 of file set.hpp.

◆ const_reference

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::const_reference = const T&

Definition at line 73 of file set.hpp.

◆ diference_type

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::diference_type = std::ptrdiff_t

Definition at line 69 of file set.hpp.

◆ hasher

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::hasher = Hash

Definition at line 70 of file set.hpp.

◆ impl_t

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_t = detail::hamts::champ<T, Hash, Equal, MemoryPolicy, B>
private

Definition at line 63 of file set.hpp.

◆ iterator

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::iterator = detail::hamts::champ_iterator<T, Hash, Equal, MemoryPolicy, B>

Definition at line 76 of file set.hpp.

◆ key_equal

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::key_equal = Equal

Definition at line 71 of file set.hpp.

◆ key_type

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::key_type = T

Definition at line 66 of file set.hpp.

◆ reference

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::reference = const T&

Definition at line 72 of file set.hpp.

◆ size_type

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::size_type = detail::hamts::size_t

Definition at line 68 of file set.hpp.

◆ transient_type

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::transient_type = set_transient<T, Hash, Equal, MemoryPolicy, B>

Definition at line 79 of file set.hpp.

◆ value_type

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
using immer::set< T, Hash, Equal, MemoryPolicy, B >::value_type = T

Definition at line 67 of file set.hpp.

Constructor & Destructor Documentation

◆ set() [1/2]

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
immer::set< T, Hash, Equal, MemoryPolicy, B >::set ( )
default

Default constructor. It creates a set of size() == 0. It does not allocate memory and its complexity is $ O(1) $.

◆ set() [2/2]

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
immer::set< T, Hash, Equal, MemoryPolicy, B >::set ( impl_t  impl)
inlineprivate

Definition at line 154 of file set.hpp.

Member Function Documentation

◆ begin()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
iterator immer::set< T, Hash, Equal, MemoryPolicy, B >::begin ( ) const
inline

Returns an iterator pointing at the first element of the collection. It does not allocate memory and its complexity is $ O(1) $.

Definition at line 92 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

◆ count()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
size_type immer::set< T, Hash, Equal, MemoryPolicy, B >::count ( const T &  value) const
inline

Returns 1 when value is contained in the set or 0 otherwise. It won't allocate memory and its complexity is effectively $ O(1) $.

Definition at line 111 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

◆ end()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
iterator immer::set< T, Hash, Equal, MemoryPolicy, B >::end ( ) const
inline

Returns an iterator pointing just after the last element of the collection. It does not allocate and its complexity is $ O(1) $.

Definition at line 98 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

◆ erase()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
set immer::set< T, Hash, Equal, MemoryPolicy, B >::erase ( const T &  value) const
inline

Returns a set without value. If the value is not in the set it returns the same set. It may allocate memory and its complexity is effectively $ O(1) $.

Definition at line 136 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_, and immer::detail::hamts::champ< T, Hash, Equal, MemoryPolicy, B >::sub().

◆ impl()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
const impl_t& immer::set< T, Hash, Equal, MemoryPolicy, B >::impl ( ) const
inline

Definition at line 149 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

◆ insert()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
set immer::set< T, Hash, Equal, MemoryPolicy, B >::insert ( value) const
inline

Returns a set containing value. If the value is already in the set, it returns the same set. It may allocate memory and its complexity is effectively $ O(1) $.

Definition at line 128 of file set.hpp.

References immer::detail::hamts::champ< T, Hash, Equal, MemoryPolicy, B >::add(), and immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

◆ operator!=()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
bool immer::set< T, Hash, Equal, MemoryPolicy, B >::operator!= ( const set< T, Hash, Equal, MemoryPolicy, B > &  other) const
inline

Definition at line 120 of file set.hpp.

◆ operator==()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
bool immer::set< T, Hash, Equal, MemoryPolicy, B >::operator== ( const set< T, Hash, Equal, MemoryPolicy, B > &  other) const
inline

◆ size()

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
size_type immer::set< T, Hash, Equal, MemoryPolicy, B >::size ( ) const
inline

Returns the number of elements in the container. It does not allocate memory and its complexity is $ O(1) $.

Definition at line 104 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_, and immer::detail::hamts::champ< T, Hash, Equal, MemoryPolicy, B >::size.

◆ transient() [1/2]

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
transient_type immer::set< T, Hash, Equal, MemoryPolicy, B >::transient ( ) const &
inline

Returns an transient form of this container, a immer::set_transient.

Definition at line 143 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

◆ transient() [2/2]

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
transient_type immer::set< T, Hash, Equal, MemoryPolicy, B >::transient ( ) &&
inline

Definition at line 145 of file set.hpp.

References immer::set< T, Hash, Equal, MemoryPolicy, B >::impl_.

Member Data Documentation

◆ impl_

◆ transient_type

template<typename T , typename Hash = std::hash<T>, typename Equal = std::equal_to<T>, typename MemoryPolicy = default_memory_policy, detail::hamts::bits_t B = default_bits>
friend immer::set< T, Hash, Equal, MemoryPolicy, B >::transient_type
private

Definition at line 152 of file set.hpp.


The documentation for this class was generated from the following file:
Released under the MIT license