home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 November
/
VPR9611B.ISO
/
vabasic
/
ntclnt.exe
/
DISK8
/
data.8
/
datab
/
INCLUDE
/
VDIC.HH
< prev
next >
Wrap
Text File
|
1996-07-29
|
4KB
|
110 lines
/*------------------------------------------------------------------------
* $Source: /rcs/crcs/general/vdic.hh,v $
* $Date: 1995/11/10 23:55:24 $ $Revision: 1.17 $
*
* Copyright 1990, Visual Edge Software Ltd.
* -----------------------------------------
* ALL RIGHTS RESERVED. This notice is intended as a precaution against
* inadvertent publication, and shall not be deemed to constitute an
* acknowledgment that publication has occurred nor to imply any waiver
* of confidentiality. The year included in the notice is the year
* of the creation of the work.
*------------------------------------------------------------------------
* Class VeDictionary
* -----------------
* A dictionary is a space-managing hash table associating string keys
* with entries over any pointer type.
* Dictionaries are -shared- by assignment, value parameter passing, etc,
* just like VArrays.
*
* This template class, based on VePDictionary, uses only a few inlines
* to wrap VePDictionary for typed use.
*---------------------------------------------------------------------------*/
#ifndef VDICO_HH
#define VDICO_HH
#include <os.h> // For NOTEMPLATES
#ifndef NOTEMPLATES
#include <visedge.hh>
#include <vstring.hh>
#include <ptrdic.hh>
#if TP_TYPE_REPEAT
#define VPD_TYPE VeDictionary<Entry>
#else
#define VPD_TYPE VeDictionary
#endif
template<class Entry> class VeDictionary : public VePDictionary
{
public:
VeDictionary() {}
VeDictionary (int hashsize) : VePDictionary(hashsize) {}
VeDictionary (const VeDictionary<Entry> &other) : VePDictionary(other) {}
VeDictionary (const VePDictionary& other) : VePDictionary(other) {}
operator= (const VePDictionary &other)
{ this->VePDictionary::operator=(other); return *this;}
/*--------------------------------------------------
* Explicit insertion of entries.
*--------------------------------------------------*/
Entry& PutAt (const char* k, const Entry e)
{return (Entry&) VePDictionary::PutAt(k, (PVoid)e); }
Entry& PutAt (const VeString& k, const Entry e)
{return (Entry&) VePDictionary::PutAt(k, (PVoid)e); }
/*--------------------------------------------------
* Extraction of entries - adding unfound ones!
*--------------------------------------------------*/
Entry& Get (const char* k)
{ return (Entry&) VePDictionary::Get(k); }
Entry& Get (const VeString& k)
{ return (Entry&) VePDictionary::Get(k); }
Entry FindElement (int &i, PVoid &aCell, VeString *aKey = 0)
{ return (Entry) VePDictionary::FindElement(i, aCell, aKey); }
Entry& operator[] (const char* k) { return Get(k); }
Entry& operator[] (const VeString& k) { return Get(k); }
/*-----------------------------------------------------
* Find out if a given key has an entry.
*-----------------------------------------------------*/
inline bool_t Query (const char* k, Entry& res)
{
PVoid result;
bool_t found = VePDictionary::Query(k, result);
res = (Entry) result;
return found;
}
inline bool_t Query (const VeString& k, Entry& res)
{
PVoid result;
bool_t found = VePDictionary::Query(k, result);
res = (Entry) result;
return found;
}
/*--------------------------------------------------
* Shrinking. Remove() returns the removed element.
*--------------------------------------------------*/
Entry Remove(const char* k)
{ return (Entry) VePDictionary::Remove(k); }
};
#endif // NOTEMPLATES
#endif