Jlm
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
jlm::util::HashSet< ItemType, HashFunctor > Class Template Reference

#include <HashSet.hpp>

Classes

class  ItemConstIterator
 

Public Member Functions

 ~HashSet () noexcept=default
 
 HashSet ()=default
 
template<class InputIt >
 HashSet (InputIt begin, InputIt end)
 
 HashSet (const HashSet &other)
 
 HashSet (HashSet &&other) noexcept
 
 HashSet (std::initializer_list< ItemType > initializerList)
 
template<typename OtherHashFunctor >
 HashSet (const std::unordered_set< ItemType, OtherHashFunctor > &other)
 
HashSetoperator= (const HashSet &other)
 
HashSetoperator= (HashSet &&other) noexcept
 
void Clear () noexcept
 
bool Contains (const ItemType &item) const noexcept
 
bool IsSubsetOf (const HashSet< ItemType > &other) const noexcept
 
std::size_t Size () const noexcept
 
bool IsEmpty () const noexcept
 
bool insert (ItemType item)
 
IteratorRange< ItemConstIteratorItems () const noexcept
 
bool UnionWith (const HashSet< ItemType > &other)
 
bool UnionWithAndClear (HashSet< ItemType > &other)
 
void IntersectWith (const HashSet< ItemType > &other)
 
void IntersectWithAndClear (HashSet< ItemType > &other)
 
void DifferenceWith (const HashSet< ItemType > &other)
 
bool Remove (ItemType item)
 
template<typename F >
size_t RemoveWhere (const F &match)
 
ItemConstIterator Erase (ItemConstIterator iterator)
 
bool operator== (const HashSet< ItemType > &other) const noexcept
 
bool operator!= (const HashSet< ItemType > &other) const noexcept
 

Private Types

using InternalSet = std::unordered_set< ItemType, HashFunctor >
 

Private Attributes

InternalSet Set_
 

Detailed Description

template<typename ItemType, typename HashFunctor = Hash<ItemType>>
class jlm::util::HashSet< ItemType, HashFunctor >

Represents a set of values. A set is a collection that contains no duplicate elements, and whose elements are in no particular order.

Template Parameters
ItemTypeThe type of the items in the hash set.

Definition at line 23 of file HashSet.hpp.

Member Typedef Documentation

◆ InternalSet

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
using jlm::util::HashSet< ItemType, HashFunctor >::InternalSet = std::unordered_set<ItemType, HashFunctor>
private

Definition at line 25 of file HashSet.hpp.

Constructor & Destructor Documentation

◆ ~HashSet()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
jlm::util::HashSet< ItemType, HashFunctor >::~HashSet ( )
defaultnoexcept

◆ HashSet() [1/6]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
jlm::util::HashSet< ItemType, HashFunctor >::HashSet ( )
default

◆ HashSet() [2/6]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
template<class InputIt >
jlm::util::HashSet< ItemType, HashFunctor >::HashSet ( InputIt  begin,
InputIt  end 
)
inline

Definition at line 99 of file HashSet.hpp.

◆ HashSet() [3/6]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
jlm::util::HashSet< ItemType, HashFunctor >::HashSet ( const HashSet< ItemType, HashFunctor > &  other)
inline

Definition at line 103 of file HashSet.hpp.

◆ HashSet() [4/6]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
jlm::util::HashSet< ItemType, HashFunctor >::HashSet ( HashSet< ItemType, HashFunctor > &&  other)
inlinenoexcept

Definition at line 107 of file HashSet.hpp.

◆ HashSet() [5/6]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
jlm::util::HashSet< ItemType, HashFunctor >::HashSet ( std::initializer_list< ItemType >  initializerList)
inline

Definition at line 111 of file HashSet.hpp.

◆ HashSet() [6/6]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
template<typename OtherHashFunctor >
jlm::util::HashSet< ItemType, HashFunctor >::HashSet ( const std::unordered_set< ItemType, OtherHashFunctor > &  other)
inlineexplicit

Definition at line 116 of file HashSet.hpp.

Member Function Documentation

◆ Clear()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
void jlm::util::HashSet< ItemType, HashFunctor >::Clear ( )
inlinenoexcept

Removes all items from a HashSet object.

Definition at line 138 of file HashSet.hpp.

◆ Contains()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::Contains ( const ItemType &  item) const
inlinenoexcept

Determines whether an HashSet object contains the specified item.

Parameters
itemThe item to locate in the HashSet object.
Returns
True if the HashSet object contains item, otherwise false.

Definition at line 150 of file HashSet.hpp.

◆ DifferenceWith()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
void jlm::util::HashSet< ItemType, HashFunctor >::DifferenceWith ( const HashSet< ItemType > &  other)
inline

Modifies this HashSet object by removing any elements that are present in other.

Parameters
otherthe HashSet used as the negative side of the set difference.

Definition at line 302 of file HashSet.hpp.

◆ Erase()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
ItemConstIterator jlm::util::HashSet< ItemType, HashFunctor >::Erase ( ItemConstIterator  iterator)
inline

Removes the element pointed to by the given iterator

Parameters
iteratorthe element to remove
Returns
an iterator to the element after the removed element

Definition at line 373 of file HashSet.hpp.

◆ insert()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::insert ( ItemType  item)
inline

Inserts the specified item to a set.

Parameters
itemThe item to add.
Returns
True if item is added to the HashSet object. False if item is already present.

Definition at line 210 of file HashSet.hpp.

◆ IntersectWith()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
void jlm::util::HashSet< ItemType, HashFunctor >::IntersectWith ( const HashSet< ItemType > &  other)
inline

Modifies this HashSet object to contain only elements that are present in itself and other.

Parameters
otherA HashSet to intersect with.

Definition at line 269 of file HashSet.hpp.

◆ IntersectWithAndClear()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
void jlm::util::HashSet< ItemType, HashFunctor >::IntersectWithAndClear ( HashSet< ItemType > &  other)
inline

Modifies this HashSet object to contain only elements both in itself and other. Consumes other, making it empty.

Parameters
otherthe HashSet to be consumed

Definition at line 286 of file HashSet.hpp.

◆ IsEmpty()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::IsEmpty ( ) const
inlinenoexcept

Determines whether the set is empty.

Returns
True if the set is empty, otherwise false.

Definition at line 198 of file HashSet.hpp.

◆ IsSubsetOf()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::IsSubsetOf ( const HashSet< ItemType > &  other) const
inlinenoexcept

Determines whether a HashSet object is a subset of other.

Parameters
otherThe HashSet to compare to the collection.
Returns
Returns true if the collection is a subset of other or equal to other, otherwise false.

Definition at line 163 of file HashSet.hpp.

◆ Items()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
IteratorRange<ItemConstIterator> jlm::util::HashSet< ItemType, HashFunctor >::Items ( ) const
inlinenoexcept

Get a iterator_range for iterating through the items in the HashSet.

Returns
A iterator_range.

Definition at line 223 of file HashSet.hpp.

◆ operator!=()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::operator!= ( const HashSet< ItemType > &  other) const
inlinenoexcept

Compares the items of this HashSet object with the items of other for inequality.

Parameters
otherHashSet object the items are compared with.
Returns
True, if the items of other are unequal the items of this HashSet object.

Definition at line 404 of file HashSet.hpp.

◆ operator=() [1/2]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
HashSet& jlm::util::HashSet< ItemType, HashFunctor >::operator= ( const HashSet< ItemType, HashFunctor > &  other)
inline

Definition at line 121 of file HashSet.hpp.

◆ operator=() [2/2]

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
HashSet& jlm::util::HashSet< ItemType, HashFunctor >::operator= ( HashSet< ItemType, HashFunctor > &&  other)
inlinenoexcept

Definition at line 128 of file HashSet.hpp.

◆ operator==()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::operator== ( const HashSet< ItemType > &  other) const
inlinenoexcept

Compares the items of this HashSet object with the items of other for equality.

Parameters
otherHashSet object the items are compared with.
Returns
True, if the items of other equal the items of this HashSet object.

Definition at line 385 of file HashSet.hpp.

◆ Remove()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::Remove ( ItemType  item)
inline

Removes the specified item from a HashSet object.

Parameters
itemThe item to remove.
Returns
True if item is successfully found and removed. False if item is not found.

Definition at line 332 of file HashSet.hpp.

◆ RemoveWhere()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
template<typename F >
size_t jlm::util::HashSet< ItemType, HashFunctor >::RemoveWhere ( const F &  match)
inline

Removes all elements that match the conditions defined by the specified match from a HashSet object.

Template Parameters
FA type supporting function call operator: bool operator(const ItemType&)
Parameters
matchDefines the condition of the elements to remove.
Returns
The number of elements that were removed from the HashSet object.

Definition at line 347 of file HashSet.hpp.

◆ Size()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
std::size_t jlm::util::HashSet< ItemType, HashFunctor >::Size ( ) const
inlinenoexcept

Get the number of items contained in the set.

Returns
The number of items contained in the set.

Definition at line 187 of file HashSet.hpp.

◆ UnionWith()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::UnionWith ( const HashSet< ItemType > &  other)
inline

Modifies this HashSet object to contain all elements that are present in itself, other, or both.

Parameters
otherA HashSet to union with.
Returns
true, if elements were added to this HashSet, otherwise false

Definition at line 236 of file HashSet.hpp.

◆ UnionWithAndClear()

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
bool jlm::util::HashSet< ItemType, HashFunctor >::UnionWithAndClear ( HashSet< ItemType > &  other)
inline

Modifies this HashSet object to contain all elements in either itself, other, or both. Consumes other, making it empty.

Parameters
otherthe HashSet to be consumed
Returns
true if elements were added to this HashSet, otherwise false

Definition at line 252 of file HashSet.hpp.

Member Data Documentation

◆ Set_

template<typename ItemType , typename HashFunctor = Hash<ItemType>>
InternalSet jlm::util::HashSet< ItemType, HashFunctor >::Set_
private

Definition at line 410 of file HashSet.hpp.


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