Simple Application Framework  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Types
Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType > Class Template Reference

Unordered set container. More...

#include <HashSet.h>

Inheritance diagram for Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >:
Saf::Algo::Struct::HashTable< ValType, ValType, Algo::Identity< ValType >, HashFuncType, HashPolicyType, CompType >

List of all members.

Public Member Functions

 HashSet (Size bucketHint=0)
 Default constructor.
 HashSet (const MyType &hs)
 Copy constructor.
MyTypeoperator= (const MyType &hs)
 Assignment operator.
MyTypeSwap (MyType &hs)
 Swap the content of two hash sets.

Protected Types

typedef
Algo::Struct::HashTable
< ValType, ValType,
Algo::Identity< ValType >
, HashFuncType, HashPolicyType,
CompType > 
BaseType
typedef HashSet< ValType,
HashFuncType, HashPolicyType,
CompType > 
MyType

Detailed Description

template<class ValType, class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
class Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >

Unordered set container.

The container stores a collection of values where each value can appear only once in the set. Internally, the data are stored in an unordered list and a hash table is used to enable fast insert, erase and look-up of the values. If a hash function is chosen appropriately, all these operations can be performed in amortized constant time.

Iterator category: Bidirectional.

Template Parameters:
ValTypeData type of the elements of the set.
HashFuncTypeUnary hash functor that takes values of ValType and returns a value of type Saf::Size.
HashPolicyTypeHash policy object that controls which hashes map to which buckets and when and how to enlarge the bucket count. The policy should never allow zero bucket count.
CompTypeA binary equality predicate on ValType. Values that have the same hash must be equal according to this predicate.
See also:
Algo::Struct::HashTable, Algo::Struct::HashTablePolicy, Algo::Hash, Collection::TreeSet.

Member Typedef Documentation

template<class ValType , class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
typedef Algo::Struct::HashTable<ValType,ValType,Algo::Identity<ValType>,HashFuncType,HashPolicyType,CompType> Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >::BaseType [protected]
template<class ValType , class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
typedef HashSet<ValType,HashFuncType,HashPolicyType,CompType> Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >::MyType [protected]

Constructor & Destructor Documentation

template<class ValType , class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >::HashSet ( Size  bucketHint = 0) [inline, explicit]

Default constructor.

Parameters:
[in]bucketHintMinimum initial number of buckets in the hash table. The actual number of buckets may be higher depending on the hash policy.
template<class ValType , class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >::HashSet ( const MyType hs) [inline]

Copy constructor.


Member Function Documentation

template<class ValType , class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
MyType& Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >::operator= ( const MyType hs) [inline]

Assignment operator.

template<class ValType , class HashFuncType = Algo::Hash<ValType>, class HashPolicyType = Algo::Struct::HashPolicy::PrimePolicy, class CompType = Algo::Predicate::Equal<ValType>>
MyType& Saf::Collection::HashSet< ValType, HashFuncType, HashPolicyType, CompType >::Swap ( MyType hs) [inline]

Swap the content of two hash sets.

Properties:

  • Worst-case time complexity: $ \mathcal{O}(1) $.

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