home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / G1 < prev    next >
Encoding:
Text File  |  1992-06-07  |  3.6 KB  |  94 lines

  1. #ifndef  __RWHASHDICT_H__
  2. #define  __RWHASHDICT_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWHashDictionary -- dictionary implemented using a hash table
  7.  *
  8.  * $Header:   E:/vcs/rw/hashdict.h_v   1.2   21 Feb 1992 12:31:04   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * $Log:   E:/vcs/rw/hashdict.h_v  $
  23.  * 
  24.  *    Rev 1.2   21 Feb 1992 12:31:04   KEFFER
  25.  * RWCollection::insert() is now private.
  26.  * 
  27.  *    Rev 1.1   28 Oct 1991 09:08:18   keffer
  28.  * Changed inclusions to <rw/xxx.h>
  29.  * 
  30.  *    Rev 1.0   28 Jul 1991 08:15:12   keffer
  31.  * Tools.h++ V4.0.5 PVCS baseline version
  32.  *
  33.  */
  34.  
  35. /*
  36.  * For the storage and retrieval of (key, value) pairs.
  37.  */
  38.  
  39. #include "rw/rwset.h"
  40.  
  41. class RWExport RWHashDictionary : public RWSet {
  42. friend class RWExport RWHashDictionaryIterator;
  43.   void            copyAssociations();
  44.   virtual RWCollectable*    insert(RWCollectable* a){ return RWSet::insert(a); }
  45. public:
  46.   RWHashDictionary(unsigned N = RWCollection::DEFAULT_CAPACITY);
  47.   RWHashDictionary(const RWHashDictionary&);
  48.   ~RWHashDictionary();
  49.  
  50.   void            operator=(const RWHashDictionary&);
  51.   RWBoolean        operator<=(const RWHashDictionary&) const;
  52.   RWBoolean        operator==(const RWHashDictionary&) const;
  53.  
  54. /***********************************************************************/
  55.  
  56.   void                applyToKeyAndValue(RWapplyKeyAndValue, void*);
  57.   virtual void            clear();
  58.   virtual void            clearAndDestroy();            // Deletes all keys AND values.
  59.   virtual RWCollectable*    find(const RWCollectable*) const;        // Returns key
  60.   RWCollectable*        findKeyAndValue(const RWCollectable* key, RWCollectable*& value) const;
  61.   RWCollectable*        findValue(const RWCollectable*) const;    // Returns value
  62.   RWCollectable*        findValue(const RWCollectable*, RWCollectable*) const; // Replace value.
  63.   RWCollectable*        insertKeyAndValue(RWCollectable* key, RWCollectable* value); // Returns key.
  64.   virtual ClassID        isA() const {return __RWHASHDICTIONARY;}
  65.   virtual RWCollectable*    newSpecies() const;
  66.   virtual RWCollectable*    remove(const RWCollectable* key);        // Returns key.
  67.   virtual void            removeAndDestroy(const RWCollectable*);    // Deletes key AND value
  68.   RWCollectable*        removeKeyAndValue(const RWCollectable* key, RWCollectable*& value);
  69. };    
  70.  
  71.  
  72. class RWExport RWHashDictionaryIterator : private RWSetIterator {
  73. public:
  74.   RWHashDictionaryIterator(RWHashDictionary& hd) : RWSetIterator(hd) { }
  75.  
  76. /*********** Virtual functions inherited from class RWIterator ***********/
  77.   RWCollectable*        findNext(const RWCollectable*);    // Find next matching item; return key
  78.   RWCollectable*        key() const;            // Return current key
  79.   RWCollectable*           operator()();            // Advance iterator, return key
  80. #ifdef NO_ACCESS_ADJUSTMENT
  81.   void                reset() { RWSetIterator::reset(); }
  82. #else
  83.   RWSetIterator::reset;
  84. #endif
  85. /******************* Special iterator functions *******************************/
  86.   RWCollectable*        remove();            // Remove current item, return key
  87.   RWCollectable*        removeNext(const RWCollectable*);    // Remove next matching item, return key
  88.   RWCollectable*        value() const;            // Return current value
  89.   RWCollectable*        value(RWCollectable*) const;    // Replace & return current value
  90. };
  91.  
  92. pragma pop_align_members();
  93. #endif /* __RWHASHDICT_H__ */
  94.