emilib
Classes | Public Types | Public Member Functions | List of all members
emilib::HashSet< KeyT, HashT, EqT > Class Template Reference

A cache-friendly hash set with open addressing, linear probing and power-of-two capacity. More...

#include <hash_set.hpp>

Classes

class  const_iterator
 
class  iterator
 

Public Types

using size_type = size_t
 
using value_type = KeyT
 
using reference = KeyT &
 
using const_reference = const KeyT &
 

Public Member Functions

 HashSet (const HashSet &other)
 
 HashSet (HashSet &&other)
 
HashSetoperator= (const HashSet &other)
 
void operator= (HashSet &&other)
 
void swap (HashSet &other)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t size () const
 
bool empty () const
 
size_t bucket_count () const
 
iterator find (const KeyT &key)
 
const_iterator find (const KeyT &key) const
 
bool contains (const KeyT &k) const
 
size_t count (const KeyT &k) const
 
std::pair< iterator, bool > insert (const KeyT &key)
 
std::pair< iterator, bool > insert (KeyT &&key)
 
template<class... Args>
std::pair< iterator, bool > emplace (Args &&... args)
 
void insert (const_iterator begin, const_iterator end)
 
void insert_unique (KeyT key)
 Same as above, but contains(key) MUST be false.
 
bool erase (const KeyT &key)
 
iterator erase (iterator it)
 
void clear ()
 Remove all elements, keeping full capacity.
 
void reserve (size_t num_elems)
 Make room for this many elements.
 

Detailed Description

template<typename KeyT, typename HashT = std::hash<KeyT>, typename EqT = HashSetEqualTo<KeyT>>
class emilib::HashSet< KeyT, HashT, EqT >

A cache-friendly hash set with open addressing, linear probing and power-of-two capacity.

Member Function Documentation

◆ erase() [1/2]

template<typename KeyT , typename HashT = std::hash<KeyT>, typename EqT = HashSetEqualTo<KeyT>>
bool emilib::HashSet< KeyT, HashT, EqT >::erase ( const KeyT &  key)
inline

Erase an element from the hash set. return false if element was not found.

◆ erase() [2/2]

template<typename KeyT , typename HashT = std::hash<KeyT>, typename EqT = HashSetEqualTo<KeyT>>
iterator emilib::HashSet< KeyT, HashT, EqT >::erase ( iterator  it)
inline

Erase an element using an iterator. Returns an iterator to the next element (or end()).

◆ insert() [1/2]

template<typename KeyT , typename HashT = std::hash<KeyT>, typename EqT = HashSetEqualTo<KeyT>>
std::pair<iterator, bool> emilib::HashSet< KeyT, HashT, EqT >::insert ( const KeyT &  key)
inline

Insert an element, unless it already exists. Returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

◆ insert() [2/2]

template<typename KeyT , typename HashT = std::hash<KeyT>, typename EqT = HashSetEqualTo<KeyT>>
std::pair<iterator, bool> emilib::HashSet< KeyT, HashT, EqT >::insert ( KeyT &&  key)
inline

Insert an element, unless it already exists. Returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.


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