home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / contain / bitset.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-26  |  2.1 KB  |  54 lines

  1. #ifndef __BITSET_H
  2. #define __BITSET_H
  3. // ╔════════════════════════════════════════════════╗
  4. // ║ bitset.h, bitset.cpp                           ║
  5. // ╟────────────────────────────────────────────────╢
  6. // ║ Bitset objects                                 ║
  7. // ╟────────────────────────────────────────────────╢
  8. // ║ Written by Gus Smedstad                        ║
  9. // ╟────────────────────────────────────────────────╢
  10. // ║ Copyright 1990 NoGate Consulting               ║
  11. // ╚════════════════════════════════════════════════╝
  12.  
  13. class bitset { /* a flexible bit set class, from -32768 to 32767 */
  14. protected:
  15.   int   low;
  16.   int   high;
  17.   char *data;
  18.   int   siz;  // in bytes of data.
  19.   void expand(int start, int stop); /* expand boundries */
  20.   void contract();                  /* shrink boundries */
  21. public:
  22.   char *info() { return data; };
  23.   bitset();
  24.   ~bitset();
  25.   bitset(int n);                   /* create with single element */
  26.   bitset(int start, int stop);     /* create with range */
  27.   bitset(bitset&);
  28.   int  max();                      /* highest bit set, or 0 */
  29.   int  min();                      /* lowest bit set, or 0 */
  30.   void set(int start, int stop);   /* set range */
  31.   void clear();                    /* clear all */
  32.   void clear(int start, int stop); /* clear range */
  33.   unsigned size();                 /* # of bits in set */
  34.   char operator [] (int);          /* element membership */
  35.   int  operator == (bitset&); 
  36.   int  operator != (bitset&);
  37.   int  operator >  (bitset&);      /* contains */
  38.   int  operator <  (bitset&);      /* is contained by */
  39.        operator void * ();         /* has elements */
  40.   int  operator ! ();              /* is empty */
  41.   bitset operator + (int);     
  42.   bitset operator - (int);     
  43.   bitset operator + (bitset&);     /* union */
  44.   bitset operator - (bitset&);     /* set difference */
  45.   bitset operator * (bitset&);     /* intersection */
  46.   bitset& operator = (bitset&);
  47.   bitset& operator += (int);
  48.   bitset& operator -= (int);
  49.   bitset& operator += (bitset&);
  50.   bitset& operator -= (bitset&);
  51.   bitset& operator *= (bitset&);
  52.  };
  53.  
  54. #endif