home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CTECHAPP.ZIP / SETS.ZIP / BITGRID.CPP next >
C/C++ Source or Header  |  1990-02-15  |  1KB  |  50 lines

  1. //  Header:     BitGrid
  2. //  Version:    2.00
  3. //
  4. //  Language:   C++ 2.0
  5. //  Environ:    Any
  6. //
  7. //  Purpose:    A class for a two-dimensional array of bits. Only those methods
  8. //              defined in this file should be used on a BitGrid.
  9. //
  10. //  Written by: Scott Robert Ladd
  11.  
  12. #if !defined(__BITGRID_HPP)
  13. #define __BITGRID_HPP 1
  14.  
  15. #include "BitSet.hpp"
  16.  
  17. class BitGrid : public BitSet
  18.     {
  19.     private:
  20.         unsigned long Width;
  21.  
  22.     public:
  23.         // constructor
  24.         BitGrid(unsigned long x_dim, unsigned long y_dim)
  25.             : BitSet(x_dim * y_dim)
  26.             {
  27.             Width = x_dim;
  28.             }
  29.  
  30.         // include a bit
  31.         void Include(unsigned long x_pos, unsigned long y_pos)
  32.             {
  33.             BitSet::Include(y_pos * Width + x_pos);
  34.             }
  35.  
  36.         // exclude a bit
  37.         void Exclude(unsigned long x_pos, unsigned long y_pos)
  38.             {
  39.             BitSet::Exclude(y_pos * Width + x_pos);
  40.             }
  41.  
  42.         //
  43.         int IsSet(unsigned long x_pos, unsigned long y_pos)
  44.             {
  45.             return BitSet::operator [] (y_pos * Width + x_pos);
  46.             }
  47.     };
  48.  
  49. #endif
  50.