Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
HashSet< T, H, A > Class Template Reference

#include <elm/data/HashSet.h>

Classes

class  Iter
 

Public Types

typedef HashSet< T, H, A > self_t
 

Public Member Functions

 HashSet (int size=211)
 
 HashSet (const HashSet< T > &s)
 
const H & hash () const
 
H & hash ()
 
const A & allocator () const
 
A & allocator ()
 
int count (void) const
 
bool contains (const T &val) const
 
template<class C >
bool containsAll (const C &coll)
 
bool isEmpty (void) const
 
 operator bool (void) const
 
Iter begin (void) const
 
Iter end (void) const
 
bool equals (const HashSet< T > &s) const
 
bool operator== (const HashSet< T > &s) const
 
bool operator!= (const HashSet< T > &s) const
 
void clear (void)
 
void add (const T &val)
 
template<class C >
void addAll (const C &coll)
 
void remove (const T &val)
 
template<class C >
void removeAll (const C &c)
 
void remove (const Iter &i)
 
void copy (const HashSet< T > &s)
 
self_t operator= (const HashSet< T > &s)
 
self_t operator+= (const T &x)
 
self_t operator-= (const T &x)
 
void insert (const T &val)
 
bool subsetOf (const HashSet< T > &s) const
 
bool operator<= (const HashSet< T > &s) const
 
bool operator>= (const HashSet< T > &s) const
 
bool operator< (const HashSet< T > &s) const
 
bool operator> (const HashSet< T > &s) const
 
void join (const HashSet< T > &c)
 
void diff (const HashSet< T > &c)
 
void meet (const HashSet< T > &c)
 
self_toperator+= (const HashSet< T > &s)
 
self_toperator|= (const HashSet< T > &s)
 
self_toperator-= (const HashSet< T > &s)
 
self_toperator&= (const HashSet< T > &s)
 
self_toperator*= (const HashSet< T > &s)
 
self_t operator+ (const HashSet< T > &s) const
 
self_t operator| (const HashSet< T > &s) const
 
self_t operator- (const HashSet< T > &s) const
 
self_t operator& (const HashSet< T > &s) const
 
self_t operator* (const HashSet< T > &s) const
 
Iter items (void) const
 
Iter operator* (void) const
 

Static Public Attributes

static const self_t null
 

Detailed Description

template<class T, class H = HashKey<T>, class A = DefaultAlloc>
class elm::HashSet< T, H, A >

Set implemented using an hash table.

Implemented Concepts
  • Collection
  • MutableCollection
  • Set
Characteristics
S is the size of the table.
  • average access time: O(n / S)
  • average add time: O(n / S)
  • average remove time: O(n / S)
  • memory space: pointer size * S + n * (data size + pointer size)
Parameters
TType of set elements.
MType of used manager (default to HashManager).

Member Typedef Documentation

◆ self_t

typedef HashSet<T, H, A> self_t

Constructor & Destructor Documentation

◆ HashSet() [1/2]

HashSet ( int  size = 211)
inline

Build an hash set with the given size. Improved efficiency is obtained with prime number as sizes.

Parameters
sizeTable size (default to 211).

◆ HashSet() [2/2]

HashSet ( const HashSet< T > &  s)
inline

Member Function Documentation

◆ add()

void add ( const T &  val)
inline

Add an item to the set.

Parameters
valAdded item.

References HashSet< T, H, A >::insert().

Referenced by HashSet< T, H, A >::addAll(), and HashSet< T, H, A >::operator+=().

◆ addAll()

void addAll ( const C &  coll)
inline

Add the given collection of items to the set.

Parameters
collAdded collection of items.

References HashSet< T, H, A >::add().

◆ allocator() [1/2]

A& allocator ( )
inline

◆ allocator() [2/2]

const A& allocator ( ) const
inline

◆ begin()

Iter begin ( void  ) const
inline

◆ clear()

void clear ( void  )
inline

Remove all items of the set.

References HashTable< T, H, A >::clear().

◆ contains()

◆ containsAll()

bool containsAll ( const C &  c)
inline

Test if all items of collection c are in the set.

Parameters
cCollection to test.
Returns
True if all collection items are in the set, false else.

References HashSet< T, H, A >::contains().

◆ copy()

void copy ( const HashSet< T > &  s)
inline

◆ count()

int count ( void  ) const
inline

Count the number of items in the set.

Returns
Count of items.

References HashTable< T, H, A >::count().

◆ diff()

void diff ( const HashSet< T > &  c)
inline

◆ end()

Iter end ( void  ) const
inline

◆ equals()

bool equals ( const HashSet< T > &  s) const
inline

◆ hash() [1/2]

H& hash ( )
inline

◆ hash() [2/2]

const H& hash ( ) const
inline

◆ insert()

void insert ( const T &  val)
inline

◆ isEmpty()

bool isEmpty ( void  ) const
inline

Test if the set is empty.

Returns
True if the set is empty, false else.

References HashTable< T, H, A >::isEmpty().

Referenced by HashSet< T, H, A >::operator bool().

◆ items()

Iter items ( void  ) const
inline

Get an iterator on the items of the set.

Returns
Iterator on the set.

Referenced by HashSet< T, H, A >::operator*().

◆ join()

◆ meet()

◆ operator bool()

operator bool ( void  ) const
inline

◆ operator!=()

bool operator!= ( const HashSet< T > &  s) const
inline

◆ operator&()

self_t operator& ( const HashSet< T > &  s) const
inline

◆ operator&=()

self_t& operator&= ( const HashSet< T > &  s)
inline

◆ operator*() [1/2]

self_t operator* ( const HashSet< T > &  s) const
inline

◆ operator*() [2/2]

Iter operator* ( void  ) const
inline

◆ operator*=()

self_t& operator*= ( const HashSet< T > &  s)
inline

◆ operator+()

self_t operator+ ( const HashSet< T > &  s) const
inline

◆ operator+=() [1/2]

self_t& operator+= ( const HashSet< T > &  s)
inline

◆ operator+=() [2/2]

self_t operator+= ( const T &  x)
inline

◆ operator-()

self_t operator- ( const HashSet< T > &  s) const
inline

◆ operator-=() [1/2]

self_t& operator-= ( const HashSet< T > &  s)
inline

◆ operator-=() [2/2]

self_t operator-= ( const T &  x)
inline

◆ operator<()

bool operator< ( const HashSet< T > &  s) const
inline

◆ operator<=()

bool operator<= ( const HashSet< T > &  s) const
inline

◆ operator=()

self_t operator= ( const HashSet< T > &  s)
inline

◆ operator==()

bool operator== ( const HashSet< T > &  s) const
inline

◆ operator>()

bool operator> ( const HashSet< T > &  s) const
inline

◆ operator>=()

bool operator>= ( const HashSet< T > &  s) const
inline

◆ operator|()

self_t operator| ( const HashSet< T > &  s) const
inline

◆ operator|=()

self_t& operator|= ( const HashSet< T > &  s)
inline

◆ remove() [1/2]

void remove ( const Iter i)
inline

Remove the item matching the iterator.

Warning
The iterator is pushed to the next item.
Parameters
iIterator on the item to remove.

References HashTable< T, H, A >::remove().

◆ remove() [2/2]

void remove ( const T &  val)
inline

Remove the given item from the set.

Parameters
valRemoved item.

References HashTable< T, H, A >::remove().

Referenced by HashSet< T, H, A >::diff(), HashSet< T, H, A >::meet(), HashSet< T, H, A >::operator-=(), and HashSet< T, H, A >::removeAll().

◆ removeAll()

void removeAll ( const C &  coll)
inline

Remove a collection of items from the set.

Parameters
collCollection of items to remove.

References HashSet< T, H, A >::remove().

◆ subsetOf()

bool subsetOf ( const HashSet< T > &  s) const
inline

Member Data Documentation

◆ null

const HashSet< T, H, A > null
static

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