AireEngine
A 3D Open-World Game Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Aire::HashSet< T > Class Template Reference

#include <hashSet.h>

Classes

struct  ConstIterator
 Iterator to iterate through the elements of a const HashSet. More...
 
struct  Iterator
 Iterator to iterate through the elements of a non-const HashSet. More...
 

Public Member Functions

 HashSet (int sizeHint=10)
 
bool insert (const T &newElement)
 
void erase (const T &element)
 
void clear ()
 
void freeMem ()
 
void reserve (size_t count)
 
Iterator find (const T &element)
 
ConstIterator find (const T &newElement) const
 
bool empty () const
 
size_t size () const
 
size_t capacity () const
 
Iterator begin ()
 
ConstIterator begin () const
 
Iterator end ()
 
ConstIterator end () const
 

Detailed Description

template<class T>
class Aire::HashSet< T >

A hash set data structure that maintains an unordered set of unique elements. Supports constant time insertion and deletion AND fast traversal.

However, iterators are invalidated on element deletion, i.e. deleting elements during traversal will lead to incorrect results.

Deletion involves member swap, so it is not advisable to store large objects.

Use this structure when fast traversal of hash set elements is required. If traversal of the whole set is not a priority, it is better to use std::unordered_set.

Member Function Documentation

◆ begin() [1/2]

template<class T >
Iterator Aire::HashSet< T >::begin ( )
inline
Returns
An iterator to the start of the HashSet.

◆ begin() [2/2]

template<class T >
ConstIterator Aire::HashSet< T >::begin ( ) const
inline
Returns
A const iterator to the start of the HashSet.

◆ capacity()

template<class T >
size_t Aire::HashSet< T >::capacity ( ) const
inline
Returns
The number of elements that can the currently allocated memory can hold.

◆ clear()

template<class T >
void Aire::HashSet< T >::clear ( )
inline

Clear the HashSet. It becomes empty (contains no elements) but the allocated memory persists.

◆ empty()

template<class T >
bool Aire::HashSet< T >::empty ( ) const
inline
Returns
True if the HashSet is empty and False otherwise.

◆ end() [1/2]

template<class T >
Iterator Aire::HashSet< T >::end ( )
inline
Returns
An iterator to the end of the HashSet.
Here is the caller graph for this function:

◆ end() [2/2]

template<class T >
ConstIterator Aire::HashSet< T >::end ( ) const
inline
Returns
A const iterator to the end of the HashSet.

◆ erase()

template<class T >
void Aire::HashSet< T >::erase ( const T & element)
inline

Remove an element from the HashSet.

Parameters
elementElement to delete.

◆ find() [1/2]

template<class T >
Iterator Aire::HashSet< T >::find ( const T & element)
inline

Find an element in the HashSet.

Parameters
elementThe element to look for.
Returns
An iterator to the element or end() iterator.
Here is the call graph for this function:

◆ find() [2/2]

template<class T >
ConstIterator Aire::HashSet< T >::find ( const T & newElement) const
inline

Find an element in the const HashSet.

Parameters
elementThe element to look for.
Returns
A const iterator to the element or end() iterator.
Here is the call graph for this function:

◆ freeMem()

template<class T >
void Aire::HashSet< T >::freeMem ( )
inline

Clear the contents of the HashSet and release any heap memory that was allocated by the containers used.

Here is the caller graph for this function:

◆ insert()

template<class T >
bool Aire::HashSet< T >::insert ( const T & newElement)
inline

Insert a new element in the HashSet.

Parameters
newElementElement to insert.
Returns
True if insertion succeeded and false if the element was already present.

◆ reserve()

template<class T >
void Aire::HashSet< T >::reserve ( size_t count)
inline

Reserve memory to hold a given number of elements. Does nothing if allocated memory is larger.

Parameters
countThe number of elements that memory should be able to fit.

◆ size()

template<class T >
size_t Aire::HashSet< T >::size ( ) const
inline
Returns
The number of elements in the HashSet.

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