Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWTValMap<K,T,C,A>

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


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/tvmap.h> 
RWTValMap<K,T,C,A> m;

Description

This class maintains a collection of keys, each with an associated item of type T. Order is determined by the key according to a comparison object of type C. C must induce a total ordering on elements of type K via a public member

which returns true if x and its partner should precede y and its partner within the collection. The structure less<T> from the C++-standard header file <functional> is an example of such a comparison object.

RWTValMap<K,T,C,A> will not accept a key that compares equal to any key already in the collection. (RWTValMultiMap<K,T,C,A> may contain multiple keys that compare equal to each other.) Equality is based on the comparison object and not on operator==. Given a comparison object comp, keys a and b are equal if

!comp(a,b) && !comp(b,a).

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

Persistence

Isomorphic.

Example

In this example, a map of RWCStrings and RWDates is exercised.

Program Output:

Related Classes

Class RWTValMultiMap<K,T,C,A> offers the same interface to a collection that accepts multiple keys that compare equal to each other. RWTValSet<T,C,A> maintains a collection of keys without the associated values.

Class std::map<K,T,C,A> is the C++-standard collection that serves as the underlying implementation for this collection.

Public Typedefs

typedef map<K,T,C,A,std::pair<K const C,T> >
  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 std::pair <const K,T>& reference; 
typedef std::const pair <const K,T>& const_reference; 

Public Constructors

RWTValMap<K,T,C,A>(const C& comp = C());
RWTValMap<K,T,C,A>(const container_type& m);
RWTValMap<K,T,C,A>(const RWTValMap<K,T,C,A>& rwm); 
RWTValMap<K,T,C,A>(const value_type* first,
   const value_type* last,const C& comp = C());

Public Member Operators

RWTValMap<K,T,C,A>&
operator=(const RWTValMap<K,T,C,A>& m); 
RWTValMap<K,T,C,A>&
operator=(const container_type& m);
bool
operator<(const RWTValMap<K,T,C,A>& m) const; 
bool
operator<(const container_type & m) const;
bool
operator==(const RWTValMap<K,T,C,A>& m) const; 
bool
operator==(const container_type & 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); 
iterator
begin();
const_iterator
begin() 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; 
bool
find(const K& key, Key& r) const; 
bool
find(bool (*fn)(const_reference,void*), void* d, 
     std::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);
map<K,T,C,std::allocator<std::pair<const K,T> > >&
std();
const map<K,T,C,std::allocator<std::pair<const K,T> > >&
std() const;

Related Global Operators

RWvostream&
operator<<(RWvostream& strm, const RWTValMap<K,T,C,A>& coll); 
RWFile&
operator<<(RWFile& strm, const RWTValMap<K,T,C,A>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTValMap<K,T,C,A>& coll); 
RWFile&
operator>>(RWFile& strm, RWTValMap<K,T,C,A>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTValMap<K,T,C,A>*& p); 
RWFile&
operator>>(RWFile& strm, RWTValMap<K,T,C,A>*& p);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, 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.