Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValHashSet<T>

Alternative interface: no Standard C++ Library


RWTValHashSet<T>-->RWTValHashTable<T>

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

Synopsis

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

Please Note!


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


Description

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

As with class RWTValHashTable<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/tvhset.h>
#include <rw/cstring.h>
#include <rw/rstream.h>

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

  set.insert("one");
  set.insert("two");
  set.insert("three");
  set.insert("one");  // Rejected: already in collection

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

Program output:

3

Public Member Functions

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


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.