fennec
Loading...
Searching...
No Matches
fennec::set< TypeT, Hash, Equals, Alloc >

wrapper for sets of elements More...

#include <set.h>

Detailed Description

template<typename TypeT, class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
struct fennec::set< TypeT, Hash, Equals, Alloc >

This data-structure behaves like a set, but does not use pointers, instead storing the table in-array

Property Value
stable
dynamic
homogenous
distinct
ordered
space \(O(N)\)
linear
access \(O(1)\)
find \(O(1)\)
insertion \(O(1)\)
deletion \(O(1)\)
Template Parameters
TypeTThe type to contain

Classes

class  iterator
 Class for Iterating the Set. More...
 

Public Member Functions

Constructors & Destructor
constexpr set ()
 Default Constructor, initializes empty set.
 
constexpr set (const hash_t &hash)
 Hash Copy Constructor, initializes empty set with a hash.
 
constexpr set (const alloc_t &alloc)
 Alloc Copy Constructor, initializes empty set with an allocator.
 
constexpr set (const hash_t &hash, const alloc_t &alloc)
 Hash Alloc Copy Constructor, initializes empty set with a hash and allocator.
 
constexpr set (const set &set)
 Set Copy Constructor.
 
constexpr set (set &&set) noexcept
 Set Move Constructor.
 
constexpr ~set ()
 Destructor, destructs all elements and releases the allocation.
 
Properties
constexpr size_t size () const
 
constexpr bool empty () const
 
constexpr size_t capacity () const
 
Access
constexpr iterator find (const elem_t &val) const
 Find an Element.
 
constexpr bool contains (const elem_t &val) const
 Check if a set contains a value.
 
constexpr elem_t * at (const iterator &it)
 Iterator Access.
 
constexpr const elem_t * at (const iterator &it) const
 Iterator Const Access.
 
Modifiers
constexpr iterator insert (elem_t &&val)
 Move Insertion.
 
constexpr iterator insert (const elem_t &val)
 Copy Insertion.
 
template<typename... ArgsT>
constexpr iterator emplace (ArgsT &&...args)
 Emplace Insertion.
 
constexpr void erase (iterator it)
 Element Erase.
 
constexpr void erase (const elem_t &val)
 Element Erase.
 
Iteration
constexpr iterator begin () const
 
constexpr iterator end () const
 

Constructor & Destructor Documentation

◆ set() [1/5]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr fennec::set< TypeT, Hash, Equals, Alloc >::set ( const hash_t &  hash)
inlineconstexpr
Parameters
hashthe hash object

◆ set() [2/5]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr fennec::set< TypeT, Hash, Equals, Alloc >::set ( const alloc_t &  alloc)
inlineconstexpr
Parameters
allocthe allocator object

◆ set() [3/5]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr fennec::set< TypeT, Hash, Equals, Alloc >::set ( const hash_t &  hash,
const alloc_t &  alloc 
)
inlineconstexpr
Parameters
hashthe hash object
allocthe allocator object

◆ set() [4/5]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr fennec::set< TypeT, Hash, Equals, Alloc >::set ( const set< TypeT, Hash, Equals, Alloc > &  set)
inlineconstexpr
Parameters
setSet to copy

◆ set() [5/5]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr fennec::set< TypeT, Hash, Equals, Alloc >::set ( set< TypeT, Hash, Equals, Alloc > &&  set)
inlineconstexprnoexcept
Parameters
setSet to move

Member Function Documentation

◆ size()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr size_t fennec::set< TypeT, Hash, Equals, Alloc >::size ( ) const
inlineconstexpr
Returns
Size of the set in elements

◆ empty()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr bool fennec::set< TypeT, Hash, Equals, Alloc >::empty ( ) const
inlineconstexpr
Returns
true when the set is empty, false otherwise

◆ capacity()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr size_t fennec::set< TypeT, Hash, Equals, Alloc >::capacity ( ) const
inlineconstexpr
Returns
Capacity of the set in elements

◆ find()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr iterator fennec::set< TypeT, Hash, Equals, Alloc >::find ( const elem_t &  val) const
inlineconstexpr
Parameters
valValue to find
Returns
An iterator at the location of the value

◆ contains()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr bool fennec::set< TypeT, Hash, Equals, Alloc >::contains ( const elem_t &  val) const
inlineconstexpr
Parameters
valValue to check
Returns
true if val can be found, false otherwise

◆ at() [1/2]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr elem_t * fennec::set< TypeT, Hash, Equals, Alloc >::at ( const iterator it)
inlineconstexpr
Parameters
itLocation to access
Returns
A pointer to the element, nullptr if not found. The value should not be changed in a manner that will change the hash of the element.

◆ at() [2/2]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr const elem_t * fennec::set< TypeT, Hash, Equals, Alloc >::at ( const iterator it) const
inlineconstexpr
Parameters
itLocation to access
Returns
A const-qualified pointer to the element, nullptr if not found.

◆ insert() [1/2]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr iterator fennec::set< TypeT, Hash, Equals, Alloc >::insert ( elem_t &&  val)
inlineconstexpr
Parameters
valValue to insert

◆ insert() [2/2]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr iterator fennec::set< TypeT, Hash, Equals, Alloc >::insert ( const elem_t &  val)
inlineconstexpr
Parameters
valValue to insert

◆ emplace()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
template<typename... ArgsT>
constexpr iterator fennec::set< TypeT, Hash, Equals, Alloc >::emplace ( ArgsT &&...  args)
inlineconstexpr
Template Parameters
ArgsTArgument types
Parameters
argsArguments to construct with

◆ erase() [1/2]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr void fennec::set< TypeT, Hash, Equals, Alloc >::erase ( iterator  it)
inlineconstexpr
Parameters
itLocation to erase

◆ erase() [2/2]

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr void fennec::set< TypeT, Hash, Equals, Alloc >::erase ( const elem_t &  val)
inlineconstexpr
Parameters
valValue to erase

◆ begin()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr iterator fennec::set< TypeT, Hash, Equals, Alloc >::begin ( ) const
inlineconstexpr
Returns
An iterator for all elements of the set in no particular order

◆ end()

template<typename TypeT , class Hash = hash<TypeT>, class Equals = equality<TypeT>, class Alloc = allocator<TypeT>>
constexpr iterator fennec::set< TypeT, Hash, Equals, Alloc >::end ( ) const
inlineconstexpr
Returns
An iterator representing the end of the set

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