Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide

RWTValHashMap<K,T,H,EQ,A>

Module:  Essential Tools Module   Group:  STL Extension-based Collection


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/tvhdict.h> 
RWTValHashMap<K,T,H,EQ,A> m;

Description

This class maintains a collection of keys, each with an associated item of type T. These pairs are stored according to a hash object of type H. H must provide a const hash function on elements of type K via public member

Equivalent keys within the collection will be grouped together based on an equality object of type EQ. EQ must ensure this grouping via public member

which should return TRUE if x and y are equivalent.

Note: Any two keys that are equivalent must hash to the same value.

RWTValHashMap<K,T,H,EQ,A> will not accept a key that is equivalent to any key already in the collection. (RWTValHashMultiMap<K,T,H,EQ,A> may contain multiple keys that are equivalent to each other.) Equality is based on an equality object and not on the == operator. If your type has an == operator, then you may want to use the templatized equal_to function object provided by the Standard C++ Library; otherwise, you must define your own equality object.

The value type must have operator==() defined. This requirement is imposed by the Standard C++ Library.

Persistence

Isomorphic

Example

Program output:

Related Classes

Class RWTValHashMultiMap<K,T,H,EQ,A> offers the same interface to a collection that accepts multiple keys that compare equal to each other.

Class rw_hashmap<K,T,H,EQ,A> is the C++-standard compliant collection that serves as the underlying implementation for this collection.

Public Typedefs

typedef rw_hashmap<K,T,H,EQ,A>  container_type; 
typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator
  const_iterator;
typedef typename container_type::size_type size_type;
typedef std::pair <const K,T> value_type; 
typedef K key_type; 
typedef T data_type; 
typedef std::pair <const K,T>& reference; 
typedef std::pair <const K,T>& const_reference; 

Public Constructors

RWTValHashMap<K,T,H,EQ,A>();
RWTValHashMap<K,T,H,EQ,A>(const rw_hashmap<K,T,H,EQ,A>& m);
RWTValHashMap<K,T,H,EQ,A>
  (const H& h, size_type sz = RWDEFAULT_CAPACITY);
RWTValHashMap<K,T,H,EQ,A>(const RWTValHashMap<K,T,H,EQ,A>& rwm);
RWTValHashMap<K,T,H,EQ,A>(const value_type* first, 
                        const value_type* last);

Public Member Operators

RWTValHashMap<K,T,H,EQ,A>&
operator=(const RWTValHashMap<K,T,H,EQ,A>& m); 
RWTValHashMap<K,T,H,EQ,A>&
operator=(const rw_hashmap<K,T,H,EQ,A>& m);
bool
operator==(const RWTValHashMap<K,T,H,EQ,A>& m) const; 
bool
operator==(const rw_hashmap<K,T,H,EQ,A>& m) const;
T&
operator[](const K& key); 

Public Member Functions

void
apply(void (*fn)(const K&, T&, void*),void* d); 
void
apply(void (*fn)(const K&,const T&,void*),void* d) const;
iterator
begin();
const_iterator
begin() const;
size_type
capacity() const; 
void
clear();
bool
contains(const K& key) const; 
bool
contains(bool (*fn)(const_reference,void*), void* d) const;
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
float
fillRatio() const; 
bool
find(const K& key, K& r) const; 
bool
find(bool (*fn)(const_reference,void*),void* d,
                pair<K,T>& r) const;
bool
findValue(const K& key, T& r) const; 
bool
findKeyValue(const K& key, K& kr, T& tr) const; 
bool
insert(const K& key, const T& a); 
bool
isEmpty() const; 
const K&
minElement() const;
const K&
maxElement() const;
size_type
occurrencesOf(const K& key) const; 
size_type
occurrencesOf(bool (*fn)(const_reference,void*),void* d)
              const;
bool
remove(const K& key); 
bool
remove(bool (*fn)(const_reference,void*), void* d);
size_type
removeAll(const K& key); 
size_type
removeAll(bool (*fn)(const_reference,void*), void* d);
void
resize(size_type sz); 
rw_hashmap<K,T,H,EQ,A>&
std();
const rw_hashmap<K,T,H,EQ,A>&
std() const;

Related Global Operators

RWvostream&
operator<<(RWvostream& strm, 
       const RWTValHashMap<K,T,H,EQ,A>& coll);
RWFile&
operator<<(RWFile& strm, const 
           RWTValHashMap<K,T,H,EQ,A>& coll);
RWvistream&
operator>>(RWvistream& strm, 
           RWTValHashMap<K,T,H,EQ,A>& coll);
RWFile&
operator>>(RWFile& strm, RWTValHashMap<K,T,H,EQ,A>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTValHashMap<K,T,H,EQ,A>*& p);
RWFile&
operator>>(RWFile& strm, RWTValHashMap<K,T,H,EQ,A>*& p);


Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.