nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Friends | List of all members
nctl::HashSetList< K, HashFunc > Class Template Reference

A template based hashset implementation with separate chaining and list head cell. More...

#include <HashSetList.h>

Public Types

using Iterator = HashSetListIterator< K, HashFunc >
 Iterator type.
 
using ConstIterator = HashSetListIterator< K, HashFunc >
 Constant iterator type.
 
using ReverseIterator = nctl::ReverseIterator< Iterator >
 Reverse iterator type.
 
using ConstReverseIterator = nctl::ReverseIterator< ConstIterator >
 Reverse constant iterator type.
 

Public Member Functions

 HashSetList (unsigned int capacity)
 
 HashSetList (const HashSetList &other)
 Copy constructor.
 
 HashSetList (HashSetList &&other)
 Move constructor.
 
HashSetListoperator= (const HashSetList &other)
 Assignment operator.
 
HashSetListoperator= (HashSetList &&other)
 Move assignment operator.
 
Iterator begin ()
 Returns an iterator to the first element.
 
ReverseIterator rBegin ()
 Returns a reverse iterator to the last element.
 
Iterator end ()
 Returns an iterator to past the last element.
 
ReverseIterator rEnd ()
 Returns a reverse iterator to prior the first element.
 
ConstIterator begin () const
 Returns a constant iterator to the first element.
 
ConstReverseIterator rBegin () const
 Returns a constant reverse iterator to the last element.
 
ConstIterator end () const
 Returns a constant iterator to past the last lement.
 
ConstReverseIterator rEnd () const
 Returns a constant reverse iterator to prior the first element.
 
ConstIterator cBegin () const
 Returns a constant iterator to the first element.
 
ConstReverseIterator crBegin () const
 Returns a constant reverse iterator to the last element.
 
ConstIterator cEnd () const
 Returns a constant iterator to past the last lement.
 
ConstReverseIterator crEnd () const
 Returns a constant reverse iterator to prior the first element.
 
bool insert (const K &key)
 Inserts an element if no other has the same key.
 
bool insert (K &&key)
 Moves an element if no other has the same key.
 
bool isEmpty () const
 Returns true if the hashSet is empty.
 
unsigned int size () const
 Returns the number of elements in the hashSet.
 
float loadFactor () const
 Returns the average number of elements per bucket,.
 
unsigned int bucketAmount () const
 Returns the number of buckets.
 
unsigned int bucketSize (const K &key) const
 Returns the size of the bucket for the hash generated by the specified key.
 
unsigned int bucket (const K &key) const
 Returns the index of the bucket for the hash generated by the specified key.
 
hash_t hash (const K &key) const
 Returns the hash of a given key.
 
void clear ()
 Clears the hashSet.
 
bool contains (const K &key) const
 Checks whether an element is in the hashSet or not.
 
K * find (const K &key)
 Checks whether an element is in the hashSet or not.
 
const K * find (const K &key) const
 Checks whether an element is in the hashSet or not (read-only)
 
bool remove (const K &key)
 Removes a key from the hashSet, if it exists.
 
void rehash (unsigned int count)
 Sets the number of buckets to the new specified size and rehashes the container.
 

Friends

class HashSetListIterator< K, HashFunc >
 
struct HashSetListHelperTraits< K, HashFunc >
 

Detailed Description

template<class K, class HashFunc = FNV1aHashFunc<K>>
class nctl::HashSetList< K, HashFunc >

A template based hashset implementation with separate chaining and list head cell.

Member Function Documentation

◆ find() [1/2]

template<class K , class HashFunc >
K * nctl::HashSetList< K, HashFunc >::find ( const K &  key)

Checks whether an element is in the hashSet or not.

Note
Prefer this method if copying T is expensive, but always check the validity of returned pointer.

◆ find() [2/2]

template<class K , class HashFunc >
const K * nctl::HashSetList< K, HashFunc >::find ( const K &  key) const

Checks whether an element is in the hashSet or not (read-only)

Note
Prefer this method if copying T is expensive, but always check the validity of returned pointer.

◆ insert() [1/2]

template<class K , class HashFunc >
bool nctl::HashSetList< K, HashFunc >::insert ( const K &  key)

Inserts an element if no other has the same key.

Returns
True if the element has been inserted

◆ insert() [2/2]

template<class K , class HashFunc >
bool nctl::HashSetList< K, HashFunc >::insert ( K &&  key)

Moves an element if no other has the same key.

Returns
True if the element has been inserted

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