Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValMultiSet<T,C>

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/tvmset.h>
RWTValMultiSet<T,C>

Standard C++ Library Dependent!


RWTPtrMultiSet requires the Standard C++ Library.


Description

This class maintains a collection of values, which are ordered according to a comparison object of type C. C must induce a total ordering on elements of type T via a public member

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

which returns true if x should precede y within the collection. The structure less<T> from the C++-standard header file <functional> is an example.

RWTValMultiSet<T,C> may contain multiple items that compare equal to each other. (RWTValSet<T,C> will not accept an item that compares equal to an item already in the collection.)

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

Persistence

Isomorphic.

Examples

In this example, a multi-set of RWCStrings is exercised.

//
// tvmsstr.cpp
//
#include <rw/tvmset.h>
#include <rw/cstring.h>
#include <iostream.h>

main(){
 RWTValMultiSet<RWCString,less<RWCString> > set;

  set.insert("one");
  set.insert("two");
  set.insert("three");
  set.insert("one");               // OK, duplicates allowed

  cout << set.entries() << endl;   // Prints "4"
  return 0;
}

Related Classes

Class RWTValSet<T,C> offers the same interface to a collection that will not accept multiple items that compare equal to each other. RWTValMultiMap<K,T,C> maintains a collection of key-value pairs.

Class multiset<T,C,allocator> is the C++-standard collection that serves as the underlying implementation for RWTValMultiSet<T,C>.

Public Typedefs

typedef multiset<T,C,allocator>                container_type; 
typedef container_type::iterator               iterator;
typedef container_type::const_iterator         const_iterator;
typedef container_type::size_type              size_type;
typedef T                                      value_type; 
typedef const T&                               const_reference; 

Public Constructors

RWTValMultiSet<T,C>(const C& cmp = C());
RWTValMultiSet<T,C>(const container_type& s);
RWTValMultiSet<T,C>(const RWTValMultiSet<T,C>& rws);
RWTValMultiSet<T,C>
(const T* first,const T* last,const C& cmp = C());

Public Member Operators

RWTValMultiSet<T,C>&
operator=(const RWTValMultiSet<T,C>& s); 
RWTValMultiSet<T,C>&
operator=(const container_type& s);
bool
operator<(const RWTValMultiSet<T,C>& s) const; 
bool
operator<(const container_type& s) const;
bool
operator==(const RWTValMultiSet<T,C>& s) const; 
bool
operator==(const container_type& s) const;

Public Member Functions

void
apply(void (*fn)(const_reference,void*), void* d) const; 
iterator
begin();
const_iterator
begin() const;
void
clear();
bool
contains(const_reference a) const; 
bool
contains(bool (*fn)(const_reference, void*), void* d) const; 
void
difference(const RWTValMultiSet<T,C>& s); 
void
difference(const container_type& s);
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
bool
find(const_reference a, T& k) const; 
bool
find(bool (*fn)(const_reference,void*), void* d, T& k) const;
void
intersection(const RWTValMultiSet<T,C>& s); 
void
intersection(const container_type& s);
bool
insert(const_reference a); 
bool
isEmpty() const; 
bool
isEquivalent(const RWTValMultiSet<T,C>& s) const; 
bool
isProperSubsetOf(const RWTValMultiSet<T,C>& s) const; 
bool
isSubsetOf(const RWTValMultiSet<T,C>& s) const; 
size_type
occurrencesOf(const_reference a) const; 
size_type
occurrencesOf(bool (*fn)(const_reference,void*),void* d) const;
bool
remove(const_reference a); 
bool
remove(bool (*fn)(const_reference,void*), void* d);
size_type
removeAll(const_reference a); 
size_type
removeAll(bool (*fn)(const_reference,void*), void* d);
multiset<T,C,allocator>&
std();
const multiset<T,C,allocator>&
std() const;
void
symmetricDifference(const RWTValMultiSet<T,C>& s); 
void
symmetricDifference(const container_type& s);
void
Union(const RWTValMultiSet<T,C>& s); 
void
Union(const container_type& s);

Related Global Operators

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


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.