MoSync 3.3
MAUtil::HashSet< Key > Class Template Reference

Thin template HashSet. More...

#include <MAUtil/HashSet.h>

Inheritance diagram for MAUtil::HashSet< Key >:
MAUtil::HashDict< const Key, const Key >

List of all members.

Public Types

typedef Key MutableStorage
typedef hash_val_t(* HashFunction )(const const Key &)
typedef int(* CompareFunction )(const const Key &, const const Key &)

Public Member Functions

 HashSet (typename D::HashFunction hf=&THashFunction< Key >, typename D::CompareFunction cf=&Compare< Key >, int init_bits=6)
Pair< typename D::Iterator, bool > insert (const Key &k)
Iterator find (const const Key &)
ConstIterator find (const const Key &) const
bool erase (const const Key &)
void erase (Iterator)
size_t size () const
void clear ()
Iterator begin ()
ConstIterator begin () const
Iterator end ()
ConstIterator end () const

Protected Types

typedef HashDict< const Key,
const Key > 
D

Protected Member Functions

Pair< Iterator, bool > insert (const const Key &)

Static Protected Member Functions

static hnode_t * alloc (void *) __attribute__((noreturn))
static void free (hnode_t *node, void *)

Protected Attributes

hash_t mHash
HashFunction mHashFunction
int mKeyOffset

Detailed Description

template<class Key>
class MAUtil::HashSet< Key >

Thin template HashSet.

See also:
HashDict

Member Typedef Documentation

template<class Key >
typedef Key MAUtil::HashSet< Key >::MutableStorage
template<class Key >
typedef HashDict<const Key, const Key> MAUtil::HashSet< Key >::D [protected]
typedef hash_val_t(* MAUtil::HashDict< const Key , const Key >::HashFunction)(const const Key &) [inherited]
typedef int(* MAUtil::HashDict< const Key , const Key >::CompareFunction)(const const Key &, const const Key &) [inherited]

Constructor & Destructor Documentation

template<class Key >
MAUtil::HashSet< Key >::HashSet ( typename D::HashFunction  hf = &THashFunction<Key>,
typename D::CompareFunction  cf = &Compare<Key>,
int  init_bits = 6 
) [inline]

Member Function Documentation

template<class Key >
Pair<typename D::Iterator, bool> MAUtil::HashSet< Key >::insert ( const Key &  k) [inline]
Iterator MAUtil::HashDict< const Key , const Key >::find ( const const Key &  ) [inherited]

Searches the HashDict for a specified Key. The returned Iterator points to the element matching the Key if one was found, or to HashDict::end() if not.

ConstIterator MAUtil::HashDict< const Key , const Key >::find ( const const Key &  ) const [inherited]
bool MAUtil::HashDict< const Key , const Key >::erase ( const const Key &  ) [inherited]

Deletes an element, matching the specified Key, from the HashDict. Returns true if an element was erased, or false if there was no element matching the Key.

void MAUtil::HashDict< const Key , const Key >::erase ( Iterator  ) [inherited]

Deletes an element, pointed to by the specified Iterator. The Iterator is invalidated, so if you want to continue iterating through the HashDict, you must use a different Iterator instance.

Warning:
If the Iterator is bound to a different HashDict, or if it points to end(), the system will crash.
size_t MAUtil::HashDict< const Key , const Key >::size ( ) const [inherited]

Returns the number of elements in the HashDict.

void MAUtil::HashDict< const Key , const Key >::clear ( ) [inherited]

Deletes all elements.

Iterator MAUtil::HashDict< const Key , const Key >::begin ( ) [inherited]

Returns an Iterator pointing to the first element in the HashDict.

ConstIterator MAUtil::HashDict< const Key , const Key >::begin ( ) const [inherited]
Iterator MAUtil::HashDict< const Key , const Key >::end ( ) [inherited]

Returns an Iterator pointing to a place beyond the last element of the HashDict. This Iterator is often used to determine when another Iterator has reached its end.

ConstIterator MAUtil::HashDict< const Key , const Key >::end ( ) const [inherited]
static hnode_t* MAUtil::HashDict< const Key , const Key >::alloc ( void *  ) [inline, static, protected, inherited]
static void MAUtil::HashDict< const Key , const Key >::free ( hnode_t *  node,
void *   
) [inline, static, protected, inherited]
Pair<Iterator, bool> MAUtil::HashDict< const Key , const Key >::insert ( const const Key &  ) [protected, inherited]

Inserts a new element into the HashMap.

Returns a Pair. The Pair's second element is true if the element was inserted, or false if the element already existed in the map. The Pair's first element is an Iterator that points to the element in the HashMap.

An element which has the same key as the new one may already be present in the HashMap; in that case, this operation does nothing, and the Iterator returned will point to the old element.

Referenced by MAUtil::HashSet< Key >::insert().


Member Data Documentation

hash_t MAUtil::HashDict< const Key , const Key >::mHash [protected, inherited]
HashFunction MAUtil::HashDict< const Key , const Key >::mHashFunction [protected, inherited]
int MAUtil::HashDict< const Key , const Key >::mKeyOffset [protected, inherited]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines