Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTPtrMultiSet<T,C>

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

Synopsis

#include <rw/tpmset.h>
RWTPtrMultiSet<T,C> s;

Standard C++ Library Dependent!


RWTPtrMultiSet requires the Standard C++ Library.


Description

This class maintains a pointer-based collection of values, which are ordered according to a comparison object of type C. Class T is the type pointed to by the items in the collection. C must induce a total ordering on elements of type T via a public member

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

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. Note that items in the collection will be dereferenced before being compared.

RWTPtrMultiSet<T,C> may contain multiple items that compare equal to each other. (RWTPtrSet<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.

//
// tpmset.cpp
//
#include <rw/tpmset.h>
#include <rw/cstring.h>
#include <iostream.h>
#include <function.h>
main(){
  RWTPtrMultiSet<RWCString, less<RWCString> > set;
  set.insert(new RWCString("one"));
  set.insert(new RWCString("two"));
  set.insert(new RWCString("three"));
  set.insert(new RWCString("one"));  // OK: duplicates allowd
  cout << set.entries() << endl;   // Prints "4"
  set.clearAndDestroy();
  cout << set.entries() << endl;   // Prints "0"
  return 0;
}

Related Classes

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

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

Public Typedefs

typedef rw_deref_compare<C,T>                  container_comp; 
typedef multiset<T*, container_comp,allocator> container_type; 
typedef container_type::size_type              size_type; 
typedef container_type::difference_type        difference_type; 
typedef container_type::iterator               iterator; 
typedef container_type::const_iterator         const_iterator; 
typedef T*                                     value_type; 
typedef T* const&                              reference; 
typedef T* const&                              const_reference; 

Public Constructors

RWTPtrMultiSet<T,C>(const container_comp& = container_comp());
RWTPtrMultiSet<T,C>(const RWTPtrMultiSet<T,C>& rws);
RWTPtrMultiSet<T,C>(const container_type>& ms);
RWTPtrMultiSet<T,C>(T* const* first,T* const* last,const container_comp& = container_comp());

Public Member Operators

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

Public Member Functions

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

Related Global Operators

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


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