home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 24 / PCPLUS115.iso / pcplus / tclite / include / set.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-28  |  1.6 KB  |  46 lines

  1. #ifndef    SET_H
  2. #define    SET_H
  3.  
  4. #include "collect.h"
  5. #include "arrayob.h"
  6.  
  7. extern const Class class_Set;
  8.  
  9. class Set: public Collection {
  10.     unsigned count;        // number of objects in set 
  11.     unsigned nbits;        // log base 2 of contents.capacity() 
  12. protected:
  13.     unsigned mask;        // contents.capacity()-1 
  14.     ArrayOb contents;    // array of set objects 
  15.     unsigned setCapacity(unsigned); // compute set allocation size
  16.     int h(unsigned long) const;   // convert hash key into contents index
  17.     Object* findObjectWithKey(const Object&) const;
  18.     virtual int findIndexOf(const Object&) const;
  19. public:
  20.     Set(unsigned size =CLTN_DEFAULT_CAPACITY);
  21.     Set(const Set&);
  22.     void operator=(const Set&);
  23.     bool operator==(const Set&) const;
  24.     bool operator!=(const Set& a) const       { return !(*this==a); }
  25.     Set operator&(const Set&) const;      // intersection
  26.     Set operator|(const Set&) const;      // union
  27.     Set operator-(const Set&) const;      // difference
  28.     virtual Object* add(const Object&);
  29.     virtual Collection& addContentsTo(Collection&) const;
  30.     virtual Object*& at(int) const;
  31.     virtual unsigned capacity() const;
  32.     virtual void    deepenShallowCopy();
  33.     virtual Object* doNext(Iterator&) const;
  34.     virtual unsigned hash() const;
  35.     virtual const Class*    isA() const;
  36.     virtual bool    isEqual(const Object&) const;
  37.     virtual unsigned occurrencesOf(const Object&) const;
  38.     virtual void    printOn(ostream& strm) const;
  39.     virtual void    reSize(unsigned);
  40.     virtual Object*    remove(const Object&);
  41.     virtual unsigned size() const;
  42.     virtual const Class*    species() const;
  43. };
  44.  
  45. #endif
  46.