home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWBAG_H__
- #define __RWBAG_H__
- pragma push_align_members(64);
-
- /*
- * Declarations for RWBag --- an unordered collection.
- *
- * $Header: E:/vcs/rw/rwbag.h_v 1.2 18 Feb 1992 09:54:36 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/rwbag.h_v $
- *
- * Rev 1.2 18 Feb 1992 09:54:36 KEFFER
- *
- * Rev 1.1 28 Oct 1991 09:08:20 keffer
- * Changed inclusions to <rw/xxx.h>
- *
- * Rev 1.0 28 Jul 1991 08:16:18 keffer
- * Tools.h++ V4.0.5 PVCS baseline version
- *
- */
-
- #include "rw/hashdict.h"
-
- class RWExport RWBagIterator;
-
- class RWExport RWBag : public RWCollection {
- friend RWBagIterator;
- unsigned totalEntries;
- RWHashDictionary contents; // Dictionary of number of occurrences.
- private:
- void deepenTally();
- public:
-
- RWBag(unsigned n = RWCollection::DEFAULT_CAPACITY);
- RWBag(const RWBag&);
- ~RWBag();
-
- /******************** Member operators ****************************/
- void operator=(const RWBag&);
- RWBoolean operator==(const RWBag&)const;
-
- /****************** Virtual member functions *******************/
- virtual void apply(RWapplyCollectable, void*);
- //virtual unsigned binaryStoreSize() const;
- virtual void clear();
- virtual void clearAndDestroy();
- //virtual int compareTo(const RWCollectable*) const;
- //virtual RWBoolean contains(const RWCollectable*) const;
- virtual unsigned entries() const {return totalEntries;}
- virtual RWCollectable* find(const RWCollectable*) const;
- //virtual unsigned hash() const;
- virtual RWCollectable* insert(RWCollectable*);
- virtual ClassID isA() const {return __RWBAG;}
- virtual RWBoolean isEmpty() const {return totalEntries==0;}
- virtual RWBoolean isEqual(const RWCollectable*) const;
- virtual RWCollectable* newSpecies() const;
- virtual unsigned occurrencesOf(const RWCollectable*) const;
- virtual RWCollectable* remove(const RWCollectable*); // Remove first occurrence
- //virtual void removeAndDestroy(const RWCollectable*);
- //virtual void restoreGuts(RWvistream&);
- //virtual void restoreGuts(RWFile&);
- //virtual void saveGuts(RWvostream&) const;
- //virtual void saveGuts(RWFile&) const;
-
- /********************* Special functions **********************************/
-
- RWCollectable* insertWithOccurrences(RWCollectable*, unsigned);
- void resize(unsigned);
- };
-
- class RWExport RWBagIterator : public RWIterator {
- RWHashDictionaryIterator contentsIterator;
- int count;
- RWCollectable* currentItem;
- public:
- RWBagIterator(const RWBag&);
-
- /******************* Virtual function inherited from RWIterator ******************/
- virtual RWCollectable* findNext(const RWCollectable*);
- virtual RWCollectable* key() const; // Return current item
- virtual RWCollectable* operator()();
- virtual void reset();
- };
-
- pragma pop_align_members();
- #endif /* __RWBAG_H__ */
-