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