home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / users / Harry / Blitz / OSProject / p4 / BitMap.h < prev    next >
Text File  |  2007-09-19  |  1KB  |  41 lines

  1. header BitMap
  2.  
  3.   uses System
  4.  
  5.   -- Each instance of this class represents a string of bits.  When the
  6.   -- object is initialized, the number of bits it will contain is specified.
  7.   -- There are methods to set, clear, and test individual bits.
  8.   --
  9.   -- The bits are indexed with numbers from 0 to (size-1).
  10.   --
  11.   -- Each instance is represented by a array of integers.
  12.   --
  13.   -- NOTE: The "Init" method allocates memory, so it should only be used
  14.   -- during kernel start-up.
  15.   --
  16.   -- NOTE: This class contains no synchronization.  If a BitMap is used by two
  17.   -- our more threads, it is up to those threads to make sure that only one
  18.   -- thread at a time touches a given BitMap object.
  19.  
  20.   class BitMap
  21.     superclass Object
  22.     fields
  23.       numBits: int
  24.       arrayOfWords: ptr to array of int
  25.     methods
  26.       Init (numberOfBits: int)        -- Allocates a private array to hold the bits.
  27.       SetBit (bitNum: int)
  28.       ClearBit (bitNum: int)
  29.       IsBitSet (bitNum: int) returns bool
  30.       Print ()                        -- Print by number, e.g., 2 4 5 7
  31.       Print2 ()                       -- Print as bitstring, e.g., 00101101
  32.       NumberOfClearBits () returns int
  33.       FindZeroAndSet () returns int   -- Find 1st zero, set it, & return its index;
  34.                                       -- Return -1 if all bits were already set.
  35.   endClass
  36.  
  37.   functions
  38.     TestBitMap ()                     -- Used in debugging this package.
  39.  
  40. endHeader
  41.