home *** CD-ROM | disk | FTP | other *** search
- #ifndef __BITSET_H
- #define __BITSET_H
- // ╔════════════════════════════════════════════════╗
- // ║ bitset.h, bitset.cpp ║
- // ╟────────────────────────────────────────────────╢
- // ║ Bitset objects ║
- // ╟────────────────────────────────────────────────╢
- // ║ Written by Gus Smedstad ║
- // ╟────────────────────────────────────────────────╢
- // ║ Copyright 1990 NoGate Consulting ║
- // ╚════════════════════════════════════════════════╝
-
- class bitset { /* a flexible bit set class, from -32768 to 32767 */
- protected:
- int low;
- int high;
- char *data;
- int siz; // in bytes of data.
- void expand(int start, int stop); /* expand boundries */
- void contract(); /* shrink boundries */
- public:
- char *info() { return data; };
- bitset();
- ~bitset();
- bitset(int n); /* create with single element */
- bitset(int start, int stop); /* create with range */
- bitset(bitset&);
- int max(); /* highest bit set, or 0 */
- int min(); /* lowest bit set, or 0 */
- void set(int start, int stop); /* set range */
- void clear(); /* clear all */
- void clear(int start, int stop); /* clear range */
- unsigned size(); /* # of bits in set */
- char operator [] (int); /* element membership */
- int operator == (bitset&);
- int operator != (bitset&);
- int operator > (bitset&); /* contains */
- int operator < (bitset&); /* is contained by */
- operator void * (); /* has elements */
- int operator ! (); /* is empty */
- bitset operator + (int);
- bitset operator - (int);
- bitset operator + (bitset&); /* union */
- bitset operator - (bitset&); /* set difference */
- bitset operator * (bitset&); /* intersection */
- bitset& operator = (bitset&);
- bitset& operator += (int);
- bitset& operator -= (int);
- bitset& operator += (bitset&);
- bitset& operator -= (bitset&);
- bitset& operator *= (bitset&);
- };
-
- #endif