libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gbl::HashSet< K, H, P > Class Template Reference
Inheritance diagram for gbl::HashSet< K, H, P >:
GblHashSet gbl::HashSetBase< HashSet< K, H, P >, K > gbl::tags::HashSet gbl::HashMap< K, T, H, P >

Public Types

using BaseType = HashSetBase< HashSet< K, H, P >, K >
 
using reference = typename BaseType::reference
 
using const_reference = typename BaseType::const_reference
 
using pointer = typename BaseType::pointer
 
using const_pointer = typename BaseType::const_pointer
 
using size_type = typename BaseType::size_type
 
using key_type = typename BaseType::key_type
 
using value_type = typename BaseType::value_type
 
using hasher = H
 
using key_equal = P
 
using iterator = HashSetIterator< HashSet< K, H, P >, K >
 
- Public Types inherited from gbl::HashSetBase< HashSet< K, H, P >, K >
using HashSetBaseType = HashSetBase< HashSet< K, H, P >, K >
 
using DerivedType = HashSet< K, H, P >
 
using KeyType = K
 
using key_type = KeyType
 
using value_type = KeyType
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using const_iterator = HashSetIterator< std::add_const_t< HashSetBase< HashSet< K, H, P >, K > >, K >
 
using allocator_type = Context *
 
using size_type = Size
 
using difference_type = ptrdiff_t
 

Public Member Functions

 HashSet (size_type capacity, const H &hash=H(), const P &pred=P(), Context *pCtx=nullptr)
 
 HashSet (size_type capacity, const H &hash, Context *pContext)
 
 HashSet (size_type capacity, Context *pContext)
 
 HashSet (type_compatible_container_readable< value_type > auto &&init, size_type capacity=0, const H hasher=H(), const P pred=P(), Context *pCtx=nullptr)
 
 HashSet (type_compatible_container_readable< value_type > auto &&init, size_type capacity, H hasher, Context *pCtx)
 
 HashSet (type_compatible_container_readable< value_type > auto &&init, size_type capacity, Context *pCtx)
 
 HashSet (type_compatible_iterator_readable< value_type > auto first, type_compatible_iterator_readable< value_type > auto last, size_type capacity=0, const H &hash=H(), const P &pred=P(), Context *pCtx=nullptr)
 
 HashSet (type_compatible_iterator_readable< value_type > auto first, type_compatible_iterator_readable< value_type > auto last, size_type capacity, const H &hash, Context *pCtx)
 
 HashSet (type_compatible_iterator_readable< value_type > auto first, type_compatible_iterator_readable< value_type > auto last, size_type capacity, Context *pCtx)
 
 HashSet (HashSet &other)
 
 HashSet (HashSet &other, Context *pCtx)
 
 HashSet (HashSet &&other)
 
 HashSet (HashSet &&other, Context *pCtx)
 
HashSetoperator= (const HashSet &other)
 
HashSetoperator= (const HashSet &&other)
 
HashSetoperator= (type_compatible_container_readable< value_type > auto &&init)
 
pointer get (const key_type &key) noexcept
 
reference at (const key_type &key)
 
iterator find (const key_type &key) noexcept
 
pointer set (const key_type &key) noexcept
 
bool insert (const key_type &key) noexcept
 
void insert_or_assign (const key_type &key) noexcept
 
bool erase (const key_type &key) noexcept
 
pointer extract (const key_type &key) noexcept
 
void clear (void) noexcept
 
template<typename... Args>
bool emplace (const key_type &key, Args &&... args)
 
template<typename... Args>
bool try_emplace (const key_type &key, Args &&... args) noexcept
 
pointer probe (size_type position) noexcept
 
iterator next (iterator *pPrev)
 
iterator begin (void)
 
iterator end (void)
 
- Public Member Functions inherited from gbl::HashSetBase< HashSet< K, H, P >, K >
 operator const GblHashSet * () const
 
decltype(autogetSet (void) const
 
decltype(autogetSet (void)
 
size_type size (void) const noexcept
 
size_type bucket_count (void) const noexcept
 
size_type bucket_size (void) const noexcept
 
bool empty (void) const noexcept
 
GblContextcontext (void) const noexcept
 
const_pointer get (const key_type &key) const noexcept
 
const_reference at (const key_type &key) const
 
size_type count (const key_type &key) const noexcept
 
bool contains (const key_type &key) const noexcept
 
const_pointer probe (size_type position) const noexcept
 
const_iterator find (const key_type &key) const noexcept
 
bool for_each (F &&fn) const noexcept
 
const_iterator next (const_iterator *pPrev) const
 
const_iterator cbegin (void) const
 
auto begin (void) const
 
const_iterator cend (void) const
 
auto end (void) const
 

Protected Member Functions

const GblHashSetset_ (void) const
 
GblHashSetset_ (void)
 

Friends

class HashSetBase< HashSet< K, H, P >, K >
 

Additional Inherited Members

- Data Fields inherited from GblHashSet
struct { 
 
   GblContext *   pCtx 
 
   size_t   entrySize 
 
   size_t   capacity 
 
   GblHashSetHashFn   pFnHash 
 
   GblHashSetCmpFn   pFnCompare 
 
   GblHashSetDtorFn   pFnDestruct 
 
   size_t   bucketSize 
 
   size_t   bucketCount 
 
   size_t   count 
 
   size_t   mask 
 
   void *   pBuckets 
 
   void *   pSpare 
 
   void *   pUserdata 
 
private_ 
 

Detailed Description

template<typename K, typename H, typename P>
class gbl::HashSet< K, H, P >

Definition at line 116 of file gimbal_hash_set.hpp.

Member Typedef Documentation

◆ BaseType

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::BaseType = HashSetBase<HashSet<K, H, P>, K>

Definition at line 123 of file gimbal_hash_set.hpp.

◆ reference

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::reference = typename BaseType::reference

Definition at line 124 of file gimbal_hash_set.hpp.

◆ const_reference

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::const_reference = typename BaseType::const_reference

Definition at line 125 of file gimbal_hash_set.hpp.

◆ pointer

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::pointer = typename BaseType::pointer

Definition at line 126 of file gimbal_hash_set.hpp.

◆ const_pointer

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::const_pointer = typename BaseType::const_pointer

Definition at line 127 of file gimbal_hash_set.hpp.

◆ size_type

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::size_type = typename BaseType::size_type

Definition at line 128 of file gimbal_hash_set.hpp.

◆ key_type

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::key_type = typename BaseType::key_type

Definition at line 129 of file gimbal_hash_set.hpp.

◆ value_type

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::value_type = typename BaseType::value_type

Definition at line 130 of file gimbal_hash_set.hpp.

◆ hasher

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::hasher = H

Definition at line 131 of file gimbal_hash_set.hpp.

◆ key_equal

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::key_equal = P

Definition at line 132 of file gimbal_hash_set.hpp.

◆ iterator

template<typename K , typename H , typename P >
using gbl::HashSet< K, H, P >::iterator = HashSetIterator<HashSet<K, H, P>, K>

Definition at line 133 of file gimbal_hash_set.hpp.

Constructor & Destructor Documentation

◆ HashSet() [1/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( size_type  capacity,
const H hash = H(),
const P pred = P(),
Context *  pCtx = nullptr 
)
inline

Definition at line 434 of file gimbal_hash_set.hpp.

437 :
438 hasher_(hash),
439 comparator_(pred)
440{
441 GblHashSet_construct(this,
442 sizeof(K),
443 hasherCb_,
444 comparatorCb_,
445 destructCb_,
446 capacity,
447 pCtx,
448 this);
449}

◆ HashSet() [2/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( size_type  capacity,
const H hash,
Context *  pContext 
)
inline

Definition at line 452 of file gimbal_hash_set.hpp.

454 :
455 HashSet(capacity, hash, P(), pContext) {}

◆ HashSet() [3/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( size_type  capacity,
Context *  pContext 
)
inline

Definition at line 458 of file gimbal_hash_set.hpp.

459 :
460 HashSet(capacity, H(), pContext) {}

◆ HashSet() [4/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( void  )
inline

Definition at line 463 of file gimbal_hash_set.hpp.

463 :
464 HashSet(0) {}

◆ HashSet() [5/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( type_compatible_container_readable< value_type > auto &&  init,
size_type  capacity = 0,
const H  hasher = H(),
const P  pred = P(),
Context *  pCtx = nullptr 
)
inline

Definition at line 467 of file gimbal_hash_set.hpp.

471 :
472 HashSet(capacity, hasher, pred, pCtx)
473{
474 for(auto&& it: init) insert(std::forward<decltype(it)>(it));
475}

◆ HashSet() [6/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( type_compatible_container_readable< value_type > auto &&  init,
size_type  capacity,
H  hasher,
Context *  pCtx 
)
inline

Definition at line 478 of file gimbal_hash_set.hpp.

481 :
482 HashSet(std::forward<decltype(init)>(init), capacity, hasher, P(), pCtx) {}

◆ HashSet() [7/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( type_compatible_container_readable< value_type > auto &&  init,
size_type  capacity,
Context *  pCtx 
)
inline

Definition at line 485 of file gimbal_hash_set.hpp.

487 :
488 HashSet(std::forward<decltype(init)>(init), capacity, H(), pCtx) {}

◆ HashSet() [8/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( type_compatible_iterator_readable< value_type > auto  first,
type_compatible_iterator_readable< value_type > auto  last,
size_type  capacity = 0,
const H hash = H(),
const P pred = P(),
Context *  pCtx = nullptr 
)
inline

Definition at line 491 of file gimbal_hash_set.hpp.

496 :
497 HashSet(capacity, hash, pred, pCtx)
498{
499 for(auto it = first; it < last; ++it) {
500 insert(*it);
501 }
502}

◆ HashSet() [9/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( type_compatible_iterator_readable< value_type > auto  first,
type_compatible_iterator_readable< value_type > auto  last,
size_type  capacity,
const H hash,
Context *  pCtx 
)
inline

Definition at line 505 of file gimbal_hash_set.hpp.

509 :
510 HashSet(std::move(first), std::move(last), capacity, hash, P(), pCtx) {}

◆ HashSet() [10/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( type_compatible_iterator_readable< value_type > auto  first,
type_compatible_iterator_readable< value_type > auto  last,
size_type  capacity,
Context *  pCtx 
)
inline

Definition at line 513 of file gimbal_hash_set.hpp.

516 :
517 HashSet(std::move(first), std::move(last), capacity, H(), pCtx) {}

◆ HashSet() [11/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( HashSet< K, H, P > &  other)
inline

Definition at line 527 of file gimbal_hash_set.hpp.

527 :
528 HashSet(other, other.context()) {}

◆ HashSet() [12/12]

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::HashSet ( HashSet< K, H, P > &  other,
Context *  pCtx 
)
inline

Definition at line 522 of file gimbal_hash_set.hpp.

522 {
523 GblHashSet_clone(this, &other, pCtx);
524}

◆ ~HashSet()

template<typename K , typename H , typename P >
gbl::HashSet< K, H, P >::~HashSet ( void  )
inline

Definition at line 531 of file gimbal_hash_set.hpp.

531 {
532 GblHashSet_destruct(this);
533}

Member Function Documentation

◆ set_() [1/2]

template<typename K , typename H , typename P >
const GblHashSet * gbl::HashSet< K, H, P >::set_ ( void  ) const
inlineprotected

Definition at line 428 of file gimbal_hash_set.hpp.

428{ return static_cast<const GblHashSet*>(this); }
Hash-table based abstract associative container with C++-style STL std::unoredered_set API.

◆ set_() [2/2]

template<typename K , typename H , typename P >
GblHashSet * gbl::HashSet< K, H, P >::set_ ( void  )
inlineprotected

Definition at line 431 of file gimbal_hash_set.hpp.

431{ return static_cast<GblHashSet*>(this); }

◆ operator=() [1/3]

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::operator= ( const HashSet< K, H, P > &  other)
inline

Definition at line 536 of file gimbal_hash_set.hpp.

536 {
537 GblHashSet_assignClone(this, &other);
538 return *this;
539}

◆ operator=() [2/3]

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::operator= ( const HashSet< K, H, P > &&  other)
inline

Definition at line 542 of file gimbal_hash_set.hpp.

542 {
543 GblHashSet_assignMove(this, &other);
544 return *this;
545}

◆ operator=() [3/3]

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::operator= ( type_compatible_container_readable< value_type > auto &&  init)
inline

Definition at line 548 of file gimbal_hash_set.hpp.

548 {
549 clear();
550 for(auto&& it: init) insert(std::forward<decltype(it)>(it));
551 return *this;
552}

◆ get()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::get ( const key_type &  key)
inlinenoexcept

Definition at line 555 of file gimbal_hash_set.hpp.

555 {
556 return static_cast<pointer>(GblHashSet_get(this, &key));
557}

◆ at()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::at ( const key_type &  key)
inline

Definition at line 560 of file gimbal_hash_set.hpp.

560 {
561 key_type* pKey = nullptr;
562 GblThread_callRecordSet(NULL, NULL);
563 pKey = reinterpret_cast<key_type*>(GblHashSet_at(this, &key));
564 Exception::checkThrow(*GblThread_callRecord(NULL));
565 return *pKey;
566}

◆ find()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::find ( const key_type &  key)
inlinenoexcept

Definition at line 569 of file gimbal_hash_set.hpp.

569 {
570 return GblHashSet_find(this, &key);
571}

◆ set()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::set ( const key_type &  key)
inlinenoexcept

Definition at line 574 of file gimbal_hash_set.hpp.

574 {
575 return static_cast<pointer>(GblHashSet_set(this, &key));
576}

◆ insert()

template<typename K , typename H , typename P >
bool gbl::HashSet< K, H, P >::insert ( const key_type &  key)
inlinenoexcept

Definition at line 579 of file gimbal_hash_set.hpp.

579 {
580 return GblHashSet_insert(this, &key);
581}

◆ insert_or_assign()

template<typename K , typename H , typename P >
void gbl::HashSet< K, H, P >::insert_or_assign ( const key_type &  key)
inlinenoexcept

Definition at line 584 of file gimbal_hash_set.hpp.

584 {
585 GblHashSet_insertOrAssign(this, &key);
586}

◆ erase()

template<typename K , typename H , typename P >
bool gbl::HashSet< K, H, P >::erase ( const key_type &  key)
inlinenoexcept

Definition at line 589 of file gimbal_hash_set.hpp.

589 {
590 return GblHashSet_erase(this, &key);
591}

◆ extract()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::extract ( const key_type &  key)
inlinenoexcept

Definition at line 594 of file gimbal_hash_set.hpp.

594 {
595 return GblHashSet_extract(this, &key);
596}

◆ clear()

template<typename K , typename H , typename P >
void gbl::HashSet< K, H, P >::clear ( void  )
inlinenoexcept

Definition at line 599 of file gimbal_hash_set.hpp.

599 {
600 GblHashSet_clear(this);
601}

◆ emplace()

template<typename K , typename H , typename P >
template<typename... Args>
bool gbl::HashSet< K, H, P >::emplace ( const key_type &  key,
Args &&...  args 
)
inline

Definition at line 618 of file gimbal_hash_set.hpp.

618 {
619 pointer pData = static_cast<pointer>(GblHashSet_emplace(this, &key));
620 GBL_ASSERT(pData);
621 new (pData) key_type(std::forward<Args>(args)...);
622 return true;
623}

◆ try_emplace()

template<typename K , typename H , typename P >
template<typename... Args>
bool gbl::HashSet< K, H, P >::try_emplace ( const key_type &  key,
Args &&...  args 
)
inlinenoexcept

Definition at line 610 of file gimbal_hash_set.hpp.

610 {
611 pointer pData = static_cast<pointer>(GblHashSet_emplace(this, &key));
612 if(pData) new (pData) key_type(std::forward<Args>(args)...);
613 return pData;
614}

◆ probe()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::probe ( size_type  position)
inlinenoexcept

Definition at line 604 of file gimbal_hash_set.hpp.

604 {
605 return reinterpret_cast<pointer>(GblHashSet_probe(this, position));
606}

◆ next()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::next ( iterator pPrev)
inline

Definition at line 626 of file gimbal_hash_set.hpp.

626 {
627 return GblHashSet_next(this, pPrev);
628}

◆ begin()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::begin ( void  )
inline

Definition at line 631 of file gimbal_hash_set.hpp.

631 {
632 return next(nullptr);
633}

◆ end()

template<typename K , typename H , typename P >
auto gbl::HashSet< K, H, P >::end ( void  )
inline

Definition at line 636 of file gimbal_hash_set.hpp.

636 {
637 return iterator(this, this->bucket_count());
638}

Friends And Related Symbol Documentation

◆ HashSetBase< HashSet< K, H, P >, K >

template<typename K , typename H , typename P >
friend class HashSetBase< HashSet< K, H, P >, K >
friend

Definition at line 103 of file gimbal_hash_set.hpp.


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