home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
WmtRWTPSetDict.hxx
< prev
next >
Wrap
Text File
|
1996-05-31
|
3KB
|
94 lines
/*---------------------------------------------------------------------------
*
* (c) Westmount Technology 1994
*
* File: @(#)WmtRWTPSetDict.hxx 1.1
* Author: peku
* Description: pointer set dictionary based on RogueWave library
*---------------------------------------------------------------------------
SccsId = @(#)WmtRWTPSetDict.hxx 1.1 21 Feb 1994 Copyright 1994 Westmount Technology */
#ifndef WMTRWTPSETDICT_HXX
#define WMTRWTPSETDICT_HXX
#ifndef __RWTVHDICT_H__
#include "rw/tvhdict.h"
#endif
#ifndef WMTRWTPTRSET_HXX
#include "WmtRWTPtrSet.hxx"
#endif
template<class K, class V>
class WmtRWTPSetDict : private RWTValHashDictionary<K, WmtRWTPtrSet<V>* > {
public:
WmtRWTPSetDict(unsigned (*hashKey)(const K&)) :
RWTValHashDictionary<K, WmtRWTPtrSet<V>* >(hashKey)
{
}
RWBoolean doFindValue(const K& key, WmtRWTPtrSet<V>* &retval) const
{
if (! RWTValHashDictionary<K, WmtRWTPtrSet<V>* >::findValue(
key, retval)) {
return FALSE;
} else {
return TRUE;
}
}
void doInsertKeyAndValue(const K& key, V *val)
{
if (! RWTValHashDictionary<K, WmtRWTPtrSet<V>* >::contains(key)) {
RWTValHashDictionary<K, WmtRWTPtrSet<V>* >::insertKeyAndValue(
key, new WmtRWTPtrSet<V>);
}
WmtRWTPtrSet<V> *set;
RWTValHashDictionary<K, WmtRWTPtrSet<V>* >::findValue(key, set);
set->doInsert(val);
}
RWBoolean doRemoveKeyAndValue(const K& key, V *val)
{
WmtRWTPtrSet<V> *set;
if (doFindValue(key, set)) {
set->doRemove(val);
if (set->doIsEmpty()) {
delete set;
}
return TRUE;
} else {
return FALSE;
}
}
//void doClear()
// { RWTValHashDictionary<K, WmtRWTPtrSet<V>* >::clear(); }
};
template <class K, class V>
class WmtRWTPSetDictIterator :
private RWTValHashDictionaryIterator<K, WmtRWTPtrSet<V>* > {
public:
WmtRWTPSetDictIterator(const WmtRWTPSetDict<K, V>& c) :
RWTValHashDictionaryIterator<K, WmtRWTPtrSet<V>* >(
(RWTValHashDictionary<K, WmtRWTPtrSet<V>* >&)c) {}
K key() const
{
return (K)RWTValHashDictionaryIterator<K, WmtRWTPtrSet<V>* >::key();
}
WmtRWTPtrSet<V> *value() const
{
return (WmtRWTPtrSet<V> *)
RWTValHashDictionaryIterator<K, WmtRWTPtrSet<V>* >::value();
}
RWBoolean operator++()
{
return RWTValHashDictionaryIterator<K, WmtRWTPtrSet<V>* >::
operator++();
}
void reset()
{
RWTValHashDictionaryIterator<K, WmtRWTPtrSet<V>* >::reset();
}
};
#endif /* WMTRWTPSETDICT_HXX */