[prev] 32 [next]

Bits ADT

ADT to represent arbitrary-length bit-strings

Bits newBits(int n);
  • create a new bit-string of length n
Bool bitIsSet(Bits b, int i);
  • check whether bit i is set to 1 in bit-string b
void setBit(Bits b, int i);
  • set the ith bit of bit-string b to 1
void unsetBit(Bits b, int i);
  • set the ith bit of bit-string b to 0
Bit-strings of length n are indexed from 0 (least sig) .. n-1 (most sig)