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

  1. #ifndef __RWBAG_H__
  2. #define __RWBAG_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * Declarations for RWBag --- an unordered collection.
  7.  *
  8.  * $Header:   E:/vcs/rw/rwbag.h_v   1.2   18 Feb 1992 09:54:36   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/rwbag.h_v  $
  23.  * 
  24.  *    Rev 1.2   18 Feb 1992 09:54:36   KEFFER
  25.  * 
  26.  *    Rev 1.1   28 Oct 1991 09:08:20   keffer
  27.  * Changed inclusions to <rw/xxx.h>
  28.  * 
  29.  *    Rev 1.0   28 Jul 1991 08:16:18   keffer
  30.  * Tools.h++ V4.0.5 PVCS baseline version
  31.  *
  32.  */
  33.  
  34. #include "rw/hashdict.h"
  35.  
  36. class RWExport RWBagIterator;
  37.  
  38. class RWExport RWBag : public RWCollection {
  39.   friend RWBagIterator;
  40.   unsigned        totalEntries;
  41.   RWHashDictionary    contents;    // Dictionary of number of occurrences.
  42. private:
  43.   void            deepenTally();
  44. public:
  45.  
  46.   RWBag(unsigned n = RWCollection::DEFAULT_CAPACITY);
  47.   RWBag(const RWBag&);
  48.   ~RWBag();
  49.  
  50.   /******************** Member operators ****************************/
  51.   void            operator=(const RWBag&);
  52.   RWBoolean        operator==(const RWBag&)const;
  53.  
  54.   /****************** Virtual member functions *******************/
  55.   virtual void            apply(RWapplyCollectable, void*);
  56. //virtual unsigned        binaryStoreSize() const;
  57.   virtual void            clear();
  58.   virtual void            clearAndDestroy();
  59. //virtual int            compareTo(const RWCollectable*) const;
  60. //virtual RWBoolean        contains(const RWCollectable*) const;
  61.   virtual unsigned        entries() const            {return totalEntries;}
  62.   virtual RWCollectable*    find(const RWCollectable*) const;
  63. //virtual unsigned        hash() const;
  64.   virtual RWCollectable*    insert(RWCollectable*);
  65.   virtual ClassID        isA() const {return __RWBAG;}
  66.   virtual RWBoolean        isEmpty() const {return totalEntries==0;}
  67.   virtual RWBoolean        isEqual(const RWCollectable*) const;
  68.   virtual RWCollectable*    newSpecies() const;
  69.   virtual unsigned        occurrencesOf(const RWCollectable*) const;
  70.   virtual RWCollectable*    remove(const RWCollectable*);    // Remove first occurrence
  71. //virtual void            removeAndDestroy(const RWCollectable*); 
  72. //virtual void            restoreGuts(RWvistream&);
  73. //virtual void            restoreGuts(RWFile&);
  74. //virtual void            saveGuts(RWvostream&) const;
  75. //virtual void            saveGuts(RWFile&) const;
  76.  
  77. /********************* Special functions **********************************/
  78.  
  79.   RWCollectable*        insertWithOccurrences(RWCollectable*, unsigned);
  80.   void                resize(unsigned);
  81. };
  82.  
  83. class RWExport RWBagIterator : public RWIterator {
  84.   RWHashDictionaryIterator    contentsIterator;
  85.   int                count;
  86.   RWCollectable*        currentItem;
  87. public:
  88.   RWBagIterator(const RWBag&);
  89.  
  90.   /******************* Virtual function inherited from RWIterator ******************/
  91.   virtual RWCollectable*    findNext(const RWCollectable*);
  92.   virtual RWCollectable*    key() const;        // Return current item
  93.   virtual RWCollectable*    operator()();
  94.   virtual void            reset();
  95. };
  96.  
  97. pragma pop_align_members();
  98. #endif /* __RWBAG_H__ */
  99.