home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWHASHDICT_H__
- #define __RWHASHDICT_H__
- pragma push_align_members(64);
-
- /*
- * RWHashDictionary -- dictionary implemented using a hash table
- *
- * $Header: E:/vcs/rw/hashdict.h_v 1.2 21 Feb 1992 12:31:04 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1989, 1990, 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/hashdict.h_v $
- *
- * Rev 1.2 21 Feb 1992 12:31:04 KEFFER
- * RWCollection::insert() is now private.
- *
- * Rev 1.1 28 Oct 1991 09:08:18 keffer
- * Changed inclusions to <rw/xxx.h>
- *
- * Rev 1.0 28 Jul 1991 08:15:12 keffer
- * Tools.h++ V4.0.5 PVCS baseline version
- *
- */
-
- /*
- * For the storage and retrieval of (key, value) pairs.
- */
-
- #include "rw/rwset.h"
-
- class RWExport RWHashDictionary : public RWSet {
- friend class RWExport RWHashDictionaryIterator;
- void copyAssociations();
- virtual RWCollectable* insert(RWCollectable* a){ return RWSet::insert(a); }
- public:
- RWHashDictionary(unsigned N = RWCollection::DEFAULT_CAPACITY);
- RWHashDictionary(const RWHashDictionary&);
- ~RWHashDictionary();
-
- void operator=(const RWHashDictionary&);
- RWBoolean operator<=(const RWHashDictionary&) const;
- RWBoolean operator==(const RWHashDictionary&) const;
-
- /***********************************************************************/
-
- void applyToKeyAndValue(RWapplyKeyAndValue, void*);
- virtual void clear();
- virtual void clearAndDestroy(); // Deletes all keys AND values.
- virtual RWCollectable* find(const RWCollectable*) const; // Returns key
- RWCollectable* findKeyAndValue(const RWCollectable* key, RWCollectable*& value) const;
- RWCollectable* findValue(const RWCollectable*) const; // Returns value
- RWCollectable* findValue(const RWCollectable*, RWCollectable*) const; // Replace value.
- RWCollectable* insertKeyAndValue(RWCollectable* key, RWCollectable* value); // Returns key.
- virtual ClassID isA() const {return __RWHASHDICTIONARY;}
- virtual RWCollectable* newSpecies() const;
- virtual RWCollectable* remove(const RWCollectable* key); // Returns key.
- virtual void removeAndDestroy(const RWCollectable*); // Deletes key AND value
- RWCollectable* removeKeyAndValue(const RWCollectable* key, RWCollectable*& value);
- };
-
-
- class RWExport RWHashDictionaryIterator : private RWSetIterator {
- public:
- RWHashDictionaryIterator(RWHashDictionary& hd) : RWSetIterator(hd) { }
-
- /*********** Virtual functions inherited from class RWIterator ***********/
- RWCollectable* findNext(const RWCollectable*); // Find next matching item; return key
- RWCollectable* key() const; // Return current key
- RWCollectable* operator()(); // Advance iterator, return key
- #ifdef NO_ACCESS_ADJUSTMENT
- void reset() { RWSetIterator::reset(); }
- #else
- RWSetIterator::reset;
- #endif
- /******************* Special iterator functions *******************************/
- RWCollectable* remove(); // Remove current item, return key
- RWCollectable* removeNext(const RWCollectable*); // Remove next matching item, return key
- RWCollectable* value() const; // Return current value
- RWCollectable* value(RWCollectable*) const; // Replace & return current value
- };
-
- pragma pop_align_members();
- #endif /* __RWHASHDICT_H__ */
-