ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
flat_set< T, Storage, hash > Struct Template Reference

Flat set with pluggable storage. More...

#include "flat_set.hpp"

Public Types

using storage_t = Storage< T >
 Underlying container type.
 
using hash_t = hash
 Hash functor type for elements.
 
using iterator = decltype(std::begin(std::declval< storage_t & >()))
 Mutable iterator.
 
using const_iterator = decltype(std::begin(std::declval< const storage_t & >()))
 Const iterator.
 

Public Member Functions

iterator begin ()
 Return iterator to the first element.
 
const_iterator begin () const
 Return const iterator to the first element.
 
const_iterator cbegin () const
 Return const iterator to the first element.
 
iterator end ()
 Return iterator past the last element.
 
const_iterator end () const
 Return const iterator past the last element.
 
const_iterator cend () const
 Return const iterator past the last element.
 
size_t size () const
 Return the number of elements in the set.
 
bool empty () const
 Return true if the set is empty.
 
void reserve (size_t n)
 Reserve storage for at least n elements.
 
size_t capacity () const
 Return the current storage capacity.
 
template<class K , class = std::enable_if_t<std::is_convertible<K, T>{}>>
iterator find (K &&k)
 Find an element equal to k.
 
template<class K , class = std::enable_if_t<std::is_convertible<K, T>{}>>
const_iterator find (K &&k) const
 Find an element equal to k (const overload).
 
iterator erase (const_iterator it)
 Remove the element at it.
 
template<class K , class = std::enable_if_t<std::is_convertible<K,T>{}>>
void insert (const K &value)
 Insert value if not already present (const-ref overload).
 
template<class K , class = std::enable_if_t<std::is_convertible<K,T>{}>>
void insert (K &&value)
 Insert value if not already present (rvalue overload).
 
bool operator== (const flat_set &rhs) const
 Compare two flat_sets for equality (order-independent).
 
bool operator< (const flat_set &rhs) const
 Less-than comparison based on minimum differing element.
 

Public Attributes

storage_t storage
 Contiguous element storage.
 

Detailed Description

template<class T, template< class ... >class Storage = std::vector, class hash = std::hash<T>>
struct flat_set< T, Storage, hash >

Flat set with pluggable storage.

Template Parameters
TElement type. Must be equality-comparable.
StorageContainer template for storage (default: std::vector).
hashHash functor for elements (used by the std::hash specialisation, default: std::hash<T>).

Definition at line 41 of file flat_set.hpp.

Member Typedef Documentation

◆ const_iterator

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
using flat_set< T, Storage, hash >::const_iterator = decltype(std::begin(std::declval<const storage_t&>()))

Const iterator.

Definition at line 47 of file flat_set.hpp.

◆ hash_t

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
using flat_set< T, Storage, hash >::hash_t = hash

Hash functor type for elements.

Definition at line 43 of file flat_set.hpp.

◆ iterator

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
using flat_set< T, Storage, hash >::iterator = decltype(std::begin(std::declval<storage_t&>()))

Mutable iterator.

Definition at line 46 of file flat_set.hpp.

◆ storage_t

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
using flat_set< T, Storage, hash >::storage_t = Storage<T>

Underlying container type.

Definition at line 42 of file flat_set.hpp.

Member Function Documentation

◆ begin() [1/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
iterator flat_set< T, Storage, hash >::begin ( )
inline

Return iterator to the first element.

Returns
Mutable begin iterator.

Definition at line 51 of file flat_set.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin() [2/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
const_iterator flat_set< T, Storage, hash >::begin ( ) const
inline

Return const iterator to the first element.

Returns
Const begin iterator.

Definition at line 56 of file flat_set.hpp.

Here is the call graph for this function:

◆ capacity()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
size_t flat_set< T, Storage, hash >::capacity ( ) const
inline

Return the current storage capacity.

Returns
Number of elements that can be stored without reallocation.

Definition at line 94 of file flat_set.hpp.

◆ cbegin()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
const_iterator flat_set< T, Storage, hash >::cbegin ( ) const
inline

Return const iterator to the first element.

Returns
Const begin iterator.

Definition at line 61 of file flat_set.hpp.

Here is the call graph for this function:

◆ cend()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
const_iterator flat_set< T, Storage, hash >::cend ( ) const
inline

Return const iterator past the last element.

Returns
Const end iterator.

Definition at line 76 of file flat_set.hpp.

Here is the call graph for this function:

◆ empty()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
bool flat_set< T, Storage, hash >::empty ( ) const
inline

Return true if the set is empty.

Returns
true if no elements are stored.

Definition at line 85 of file flat_set.hpp.

◆ end() [1/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
iterator flat_set< T, Storage, hash >::end ( )
inline

Return iterator past the last element.

Returns
Mutable end iterator.

Definition at line 66 of file flat_set.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [2/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
const_iterator flat_set< T, Storage, hash >::end ( ) const
inline

Return const iterator past the last element.

Returns
Const end iterator.

Definition at line 71 of file flat_set.hpp.

Here is the call graph for this function:

◆ erase()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
iterator flat_set< T, Storage, hash >::erase ( const_iterator  it)
inline

Remove the element at it.

Parameters
itIterator to the element to remove.
Returns
Iterator to the element following the removed one.

Definition at line 121 of file flat_set.hpp.

◆ find() [1/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
template<class K , class = std::enable_if_t<std::is_convertible<K, T>{}>>
iterator flat_set< T, Storage, hash >::find ( K &&  k)
inline

Find an element equal to k.

Parameters
kElement to search for.
Returns
Iterator to the element, or end() if not found.

Definition at line 104 of file flat_set.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find() [2/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
template<class K , class = std::enable_if_t<std::is_convertible<K, T>{}>>
const_iterator flat_set< T, Storage, hash >::find ( K &&  k) const
inline

Find an element equal to k (const overload).

Parameters
kElement to search for.
Returns
Const iterator to the element, or end() if not found.

Definition at line 113 of file flat_set.hpp.

Here is the call graph for this function:

◆ insert() [1/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
template<class K , class = std::enable_if_t<std::is_convertible<K,T>{}>>
void flat_set< T, Storage, hash >::insert ( const K &  value)
inline

Insert value if not already present (const-ref overload).

Parameters
valueElement to insert.

Definition at line 129 of file flat_set.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [2/2]

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
template<class K , class = std::enable_if_t<std::is_convertible<K,T>{}>>
void flat_set< T, Storage, hash >::insert ( K &&  value)
inline

Insert value if not already present (rvalue overload).

Parameters
valueElement to insert (moved).

Definition at line 140 of file flat_set.hpp.

Here is the call graph for this function:

◆ operator<()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
bool flat_set< T, Storage, hash >::operator< ( const flat_set< T, Storage, hash > &  rhs) const
inline

Less-than comparison based on minimum differing element.

Parameters
rhsRight-hand side set.
Returns
true if this set is less than rhs.

Definition at line 168 of file flat_set.hpp.

Here is the call graph for this function:

◆ operator==()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
bool flat_set< T, Storage, hash >::operator== ( const flat_set< T, Storage, hash > &  rhs) const
inline

Compare two flat_sets for equality (order-independent).

Parameters
rhsRight-hand side set.
Returns
true if both sets contain the same elements.

Definition at line 152 of file flat_set.hpp.

Here is the call graph for this function:

◆ reserve()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
void flat_set< T, Storage, hash >::reserve ( size_t  n)
inline

Reserve storage for at least n elements.

Parameters
nMinimum capacity.

Definition at line 90 of file flat_set.hpp.

◆ size()

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
size_t flat_set< T, Storage, hash >::size ( ) const
inline

Return the number of elements in the set.

Returns
Element count.

Definition at line 81 of file flat_set.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ storage

template<class T , template< class ... >class Storage = std::vector, class hash = std::hash<T>>
storage_t flat_set< T, Storage, hash >::storage

Contiguous element storage.

Definition at line 44 of file flat_set.hpp.


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