Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

BitStrings


Detailed Description

Implementation of a string of bits.

A bitstring is a memory efficient implementation of a sequence of Boolean information with arbitrary but fixed length.

Data Structures

Defines

Functions


Define Documentation

#define BITS_PER_BYTE   8
 

defines our version of a BYTE definition

Definition at line 48 of file bitstring.c.

#define BITS_PER_LONG   (BITS_PER_BYTE*BYTES_PER_LONG)
 

defines the number of bits in an unsigned long integer

Definition at line 58 of file bitstring.c.

Referenced by bitClear(), bitGet(), bitNew(), bitSet(), and resize().

#define BYTES_PER_LONG   sizeof(unsigned long)
 

defines the size of an unsigned long

Definition at line 53 of file bitstring.c.

Referenced by bitClearAll(), bitClone(), bitCopy(), bitNew(), bitSetAll(), and resize().

#define check_magic bs   ) 
 

this is defined to a null operation when debugging is switched off.

Switch it on by compiling with -DBITSTRINGS_DEBUG Definition at line 121 of file bitstring.c.

Referenced by bitAnd(), bitCheck(), bitClear(), bitClearAll(), bitClone(), bitCopy(), bitDelete(), bitGet(), bitIsAllCleared(), bitIsAllSet(), bitOr(), bitPrint(), bitSet(), bitSetAll(), bitSize(), bvAddElement(), bvAndElement(), bvCapacity(), bvClone(), bvDelete(), bvElement(), bvInsertElement(), bvIsEmpty(), bvNotElement(), bvOrElement(), bvRemoveElement(), bvSetElement(), bvSetElements(), bvSize(), and resize().

#define E_SIZEMISMATCH   -1
 

return code for size error messages

Definition at line 63 of file bitstring.c.


Function Documentation

BitString bitAnd BitString  a,
BitString  b
 

computes a logical AND between two sets of bits

sets all the bits in bitstring a that are set to 0 in bitstring b to 0. bitstring b is never modified. the bitstrings must be of the same size.

Parameters:
a the first set of bits
b the second set of bits
Returns:
a on success and NULL on failure.
Definition at line 368 of file bitstring.c.

References check_magic.

Boolean bitCheck BitString  a,
BitString  b
 

checks whether two sets have bits switched on in common

Parameters:
a the first set
b the second set of bits
Returns:
TRUE on the first common bit (i.e. two bits at the same position which are switched on); otherwise false is returned, that there are no common bits switched on. a->size == b->size
Definition at line 424 of file bitstring.c.

References check_magic.

void bitClear BitString  bs,
int  no
 

clears a bit.

if no is larger than current size the bitstring is enlarged. intermediate bits are cleared. Bits are numbered from zero upward

Parameters:
bs the bitstring from which a bit has to be cleared.
no the bit number that has to be cleared.
Definition at line 321 of file bitstring.c.

References BITS_PER_LONG, check_magic, and resize().

void bitClearAll BitString  bs  ) 
 

sets all bits to zero.

Parameters:
bs the bitstring whose bits are to be cleared.
Returns:
the new bitstring after setting all its bits to zero.
Definition at line 350 of file bitstring.c.

References BYTES_PER_LONG, and check_magic.

BitString bitClone BitString  bs  ) 
 

creates a new bitstring which is a complete clone of bs.

Parameters:
bs the bit string that has to be cloned
Returns:
a copy of the bitstring after cloning.
Definition at line 175 of file bitstring.c.

References bitNew(), BYTES_PER_LONG, and check_magic.

BitString bitCopy BitString  dst,
BitString  src
 

copies information from src to dst.

dst and src must be bitstrings of the same size

Parameters:
dst destination BitString
src source Bitstring
Returns:
1 on success, 0 on failure (e. g. , due to size mismatch)
Definition at line 197 of file bitstring.c.

References BYTES_PER_LONG, and check_magic.

void bitDelete BitString  bs  ) 
 

deletes bitstring bs and frees memory.

Parameters:
bs the bitstring that has to be deleted.
Definition at line 214 of file bitstring.c.

References check_magic.

Boolean bitGet BitString  bs,
int  no
 

test for a bit

This function checks whether a bitstring has bit at a certain position switched on.

Parameters:
bs the bitstring
no the position where to look at
Returns:
the state of the bit at the given position
Definition at line 454 of file bitstring.c.

References BITS_PER_LONG, and check_magic.

Referenced by bitPrint().

Boolean bitIsAllCleared BitString  bs  ) 
 

checks whether all bits are cleared

Parameters:
bs the bitstring we are talking about
Returns:
FALSE on the first bit being switched on, or TRUE if all are switched off
Definition at line 475 of file bitstring.c.

References check_magic.

Boolean bitIsAllSet BitString  bs  ) 
 

checks whether all bits are set

See also:
bitIsAllCleared
Parameters:
bs the current bitstring
Returns:
FALSE on the first bit being swithced off, or TRUE of all bits are switched on
Definition at line 498 of file bitstring.c.

References check_magic.

BitString bitNew int  size  ) 
 

creates a new bitstring with an initial size of size bits.

Parameters:
size specifies the size of the new bit vector to be created.
Returns:
a new bit vector of the specified size.
Definition at line 132 of file bitstring.c.

References BITS_PER_LONG, and BYTES_PER_LONG.

Referenced by bitClone().

BitString bitOr BitString  a,
BitString  b
 

computes a logical OR between two sets of bits

sets all the bits in bitstring a that are set to 1 in bitstring b to 1. bitstring b is never modified. the bitstrings must be of the same size.

Parameters:
a the first set of bits
b the second set of bits
Returns:
a on success and NULL on failure.
Definition at line 397 of file bitstring.c.

References check_magic.

void bitPrint BitString  bs  ) 
 

prints a bitstring to stdout.

Parameters:
bs the BitString to be printed
Definition at line 240 of file bitstring.c.

References bitGet(), and check_magic.

void bitSet BitString  bs,
int  no
 

sets a bit.

if no is larger than current size the bitstring is enlarged. intermediate bits are cleared. Bits are numbered from zero upwards.

Parameters:
bs the bitstring in which a bit has to be set.
no the number of the bit that has to be set
Definition at line 302 of file bitstring.c.

References BITS_PER_LONG, check_magic, and resize().

void bitSetAll BitString  bs  ) 
 

sets all the bits to one.

Parameters:
bs the bitstring whose bits are to be set.
Returns:
the new bitstring after setting all its bits to 1.
Definition at line 336 of file bitstring.c.

References BYTES_PER_LONG, and check_magic.

int bitSize BitString  bs  ) 
 

returns the size of bitstring bs.

Parameters:
bs the bitstring whose size has to be determined.
Returns:
the size of the bitstring bs
Definition at line 228 of file bitstring.c.

References check_magic.

void resize BitString  bs,
int  size
[static]
 

resize bs to size size; sets length, mask and size.

Parameters:
bs the bitstring that has to be resized.
size the size to which the bitstring has to be resized.
Returns:
the new resized bitstring.
Definition at line 259 of file bitstring.c.

References BITS_PER_LONG, and BYTES_PER_LONG.


BLAH 0.95 (20 Oct 2004)