next up previous contents index
Next: 6.2 SsBitMatD Up: 6 Bit arrays and Previous: 6 Bit arrays and

6.1 SsBitSet(SsBSLength) - Boolean Bit Array

   

Name

SsBitSet(SsBSLength) - a bit array.

Syntax

class SsBitSet(SsBSLength)
{
  // Used to hold bitpatterns and inverse bitpatterns.
  static unsigned char bitpat[8];
  static unsigned char invpat[8];

  unsigned char bits[(SsBSLength+7)/8];          // The bit set.

  public:

  SsBitSet(SsBSLength)();
  SsBitSet(SsBSLength)(const SsBitSet(SsBSLength)& bs);
  inline ~SsBitSet(SsBSLength)(){}

  inline const
  SsBitSet(SsBSLength)& operator= (const SsBitSet(SsBSLength)& bs);

  void           reset();
  inline void    set(unsigned int i);
  inline void    unset(unsigned int i);
  inline SsBool  isSet(unsigned int i) const;
  void           copyFrom(const SsBitSet(SsBSLength)& from);

  // input and output

  void print (Os os) const;
  void scan  (Is is);

  friend Os& operator << (Os& os, const SsBitSet(SsBSLength)& x);
  friend Is& operator >> (Is& is, SsBitSet(SsBSLength)& x);
};

Keywords

boolean array , bit set 

Description

SsBitSet is used to store true/ false values in an array. For efficiency it is a template class parameterized with the length so that the length is set on compile time. Thus SsBSLength should always be an integer.

Member functions

The member functions set and unset turns the bits on and off respectively. The member reset turns all bits off (default). The member isSet returns SsTRUE if the bit was set by set. The member copyFrom sets all bits equal to those of from.



next up previous contents index
Next: 6.2 SsBitMatD Up: 6 Bit arrays and Previous: 6 Bit arrays and



$addr