Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTPtrHashSet<T>

Alternative interface: no Standard C++ Library


RWTPtrHashSet<T>-->RWTPtrHashTable<T>

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

Synopsis

#include <rw/tphset.h>
unsigned hashFun(const T&);
RWTPtrHashSet(hashFun) set;

Please Note!


If you do not have the Standard C++ Library, use the interface described here. Otherwise, use the interface to RWTPtrHashSet described in the Class Reference.


Description

RWTPtrHashSet<T> is a derived class of RWTPtrHashTable<T> where the insert() function has been overridden to accept only one item of a given value. Hence, each item in the collection will have a unique value.

As with class RWTPtrHashTable<T>, you must supply a hashing function to the constructor.

The class T must have:

Persistence

None

Example

This examples exercises a set of RWCStrings.

#include <rw/tphset.h>
#include <rw/cstring.h>
#include <rw/rstream.h>

main()  { 
  RWTPtrHashSet<RWCString> set(RWCString::hash);

  set.insert(new RWCString("one"));
  set.insert(new RWCString("two"));
  set.insert(new RWCString("three"));
  set.insert(new RWCString("one"));

  cout << set.entries() << endl;  // Prints "3"

  set.clearAndDestroy();
  return 0;
}
 

Program output:

3

Public Constructor

RWTPtrHashSet<T>(unsigned (*hashFun)(const T&),
                 size_t buckets = RWDEFAULT_CAPACITY);

Public Member Operator

RWBoolean
operator!=(const RWTPtrHashSet<T>& h) const;

Public Member Functions

void
apply(void (*applyFun)(T*, void*), void* d);
void
clear();
void
clearAndDestroy();
RWBoolean
contains(const T* a) const;
RWTPtrHashSet<T>&
difference(const RWTPtrHashSet<T>& h);
size_t
entries() const;
T*
find(const T* target) const;
void
insert(T* a);
RWTPtrHashSet<T>&
intersection(const RWTPtrHashSet<T>& h);
RWBoolean
isEmpty() const;
RWBoolean
isSubsetOf(const RWTPtrHashSet<T>& h) const;
RWBoolean
isProperSubsetOf(const RWTPtrHashSet<T>& h) const;
RWBoolean
isEquivalent(const RWTPtrHashSet<T>& h) const;
size_t
occurrencesOf(const T* a) const;
T*
remove(const T* a);
size_t
removeAll(const T* a);
void
resize(size_t N);
RWTPtrHashSet<T>&
symmetricDifference(const RWTPtrHashSet<T>& h);
RWTPtrHashSet<T>&
Union(const RWTPtrHashSet<T>& h);


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