home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 November
/
VPR9611B.ISO
/
vabasic
/
ntclnt.exe
/
DISK8
/
data.8
/
datab
/
INCLUDE
/
PTRDIC.HH
< prev
next >
Wrap
Text File
|
1996-07-29
|
4KB
|
116 lines
/*------------------------------------------------------------------------
* $Source: /rcs/crcs/general/ptrdic.hh,v $
* $Date: 1995/11/10 23:55:40 $ $Revision: 1.11 $
*
* Copyright 1993, 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 VePDictionary
* -----------------
* A dictionary is a space-managing hash table associating string keys
* with pointer entries.
*
* VDictionaries are -shared- by assignment, value parameter passing, etc,
* just like VArrays.
*---------------------------------------------------------------------------*/
#ifndef VPTRDIC_HH
#define VPTRDIC_HH
#include <visedge.hh>
#include <dllclass.hh>
#include <vstring.hh>
class VPDicoCell;
#ifdef NOTEMPLATES
#include <mst/dicelary.mst>
#else
#include <varray.hh>
typedef VeArray<VPDicoCell *> VePDicoCellArray;
#endif
class VePDictionary : public VeDllBasedClass
{
public:
VOPERDECL VePDictionary ();
VOPERDECL VePDictionary (int hashsize);
VOPERDECL VePDictionary (const VePDictionary&);
virtual VOPERDECL ~VePDictionary();
VMETHODDECL(VePDictionary&) operator=(const VePDictionary&);
VOPERDECL operator int(); // return hash size
/*--------------------------------------------------
* Explicit insertion of entries.
*--------------------------------------------------*/
VMETHODDECL(PVoid&) PutAt (const char*, const PVoid);
VMETHODDECL(PVoid&) PutAt (const VeString&, const PVoid);
/*--------------------------------------------------
* Extraction of entries - adding unfound ones!
*--------------------------------------------------*/
VMETHODDECL(PVoid&) operator[] (const char*);
VMETHODDECL(PVoid&) operator[] (const VeString& );
VMETHODDECL(PVoid&) Get (const char*);
VMETHODDECL(PVoid&) Get (const VeString&);
VMETHODDECL(bool_t) Query (const char*, PVoid& entry);
VMETHODDECL(bool_t) Query (const VeString&, PVoid& entry);
VMETHODDECL(PVoid) FindElement(int &i, PVoid &cell,
VeString *aKey = 0);
/*--------------------------------------------------
* Shrinking. Remove() returns the removed element.
*--------------------------------------------------*/
VMETHODDECL(PVoid) Remove (const char* key);
VMETHODDECL(void) RemoveAll ();
/*--------------------------------------------------
* Iteration over a dictionary is done using keys.
*--------------------------------------------------*/
VMETHODDECL(const char*) FirstKey();
VMETHODDECL(const char*) NextKey(const char*);
/*--------------------------------------------------
* Find an element (== PVoid, or supplied predicate)
*--------------------------------------------------*/
VMETHODDECL(const char*) KeyOf (const PVoid e) ;
VMETHODDECL(bool_t) HasKey (const char* key) ;
/*--------------------------------------------------
* Copying. These make unshared duplicates.
*--------------------------------------------------*/
VMETHODDECL(VePDictionary) Duplicate () ;
VMETHODDECL(void) BecomeLike (VePDictionary&);
private:
VPDicoCell* FindCell(const char*, int& index);
/*-----------------------------------------------------
* INVARIANT (itsTable.Length() == itsHashSize)
*-----------------------------------------------------*/
VePDicoCellArray itsTable;
int itsHashSize;
};
#endif // VPTRDIC_HH