Click on the banner to return to the Class Reference home page.

©Copyright 1996 Rogue Wave Software

RWTValHashMap<K,T,H,EQ>

Synopsis

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

Please Note!


If you have the Standard C++ Library, use the interface described here. Otherwise, use the interface for RWTValHashDictionary described in Appendix A.


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 hash function on elements of type K via a public member

unsigned long operator()(const K& x)

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

bool operator()(const K& x, const K& y)

which should return true if x and y are equivalent.

RWTValHashMap<K,T,H,EQ> will not accept a key that compares equal to any key already in the collection. (RWTValHashMultiMap<K,T,H,EQ> may contain multiple keys that compare equal to each other.) Equality is based on the equality object and not on the == operator.

Persistence

Isomorphic

Related Classes

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

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

Public Typedefs

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

Public Constructors

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

Public Member Operators

RWTValHashMap<K,T,H,EQ>&
operator=(const RWTValHashMap<K,T,H,EQ>& m);
RWTValHashMap<K,T,H,EQ>&
operator=(const rw_hashmap<K,T,H,EQ>& m);
bool
operator==(const RWTValHashMap<K,T,H,EQ>& m) const;
bool
operator==(const rw_hashmap<K,T,H,EQ>& 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;
void
applyToKeyAndValue(void (*fn)(const K&, T&,void*),void* d);
void
applyToKeyAndValue
(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
insertKeyAndValue(const K& key,const T& a);
bool
isEmpty() 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>&
std();
const rw_hashmap<K,T,H,EQ>&
std() const;

Related Global Operators

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