MeatAxe
2.4
|
Bit strings can be written to and read from files.
The file format consists of a header followed by the data. The header contains three 32-bit integers. The first number is $-3$, the second number is the size of the bit string, and the third number is always zero. The file header is followed by the bit string data which is written as a sequence of 32-bit integers where bit 0 of the first integer contains the first bit of the string.
Data Structures | |
class | BitString_t |
A bit string. More... | |
Functions | |
int | BsAnd (BitString_t *dest, const BitString_t *src) |
Intersection of two bit strings. More... | |
int | BsIsValid (const BitString_t *bs) |
Check if a bit string is valid. More... | |
BitString_t * | BsAlloc (int size) |
Create a bit string. More... | |
int | BsFree (BitString_t *bs) |
Free a bit string. More... | |
BitString_t * | BsDup (const BitString_t *src) |
Duplicate a bit string. More... | |
int | BsIsSub (const BitString_t *a, const BitString_t *b) |
Bit string incidence relation. More... | |
int | BsIntersectionCount (const BitString_t *a, const BitString_t *b) |
Intersection count. More... | |
int | BsMinus (BitString_t *dest, const BitString_t *src) |
Difference of two bit strings. More... | |
int | BsClearAll (BitString_t *bs) |
Clear a bit string This function clears all bits in a bit string. More... | |
int | BsCompare (const BitString_t *a, const BitString_t *b) |
Compare two bit strings. More... | |
BitString_t * | BsCopy (BitString_t *dest, const BitString_t *src) |
Copy a bit string. More... | |
int | BsOr (BitString_t *dest, const BitString_t *src) |
Union of two bit strings. More... | |
void | BsPrint (const char *name, const BitString_t *bs) |
Print a bit string on stdout. More... | |
BitString_t * | BsRead (FILE *f) |
Read a bit string from a file. More... | |
int | BsWrite (BitString_t *bs, FILE *f) |
Write a bit string to a file. More... | |
int | BsSet (BitString_t *bs, int i) |
Set one bit in a bit string. More... | |
int | BsClear (BitString_t *bs, int i) |
Clear one bit in a bit string. More... | |
int | BsTest (const BitString_t *bs, int i) |
Test a bit in a bit string. More... | |
BitString_t* BsAlloc | ( | int | size | ) |
Create a bit string.
This function creates a new bit string of the specified size. The new bit string is filled with zeros.
size | Size of the bit string. |
int BsAnd | ( | BitString_t * | dest, |
const BitString_t * | src | ||
) |
Intersection of two bit strings.
This function performs a bitwise "and" operation on the operands and stores the result in dest. Both bit strings must have the same size.
int BsClear | ( | BitString_t * | bs, |
int | i | ||
) |
Clear one bit in a bit string.
This function clears a single bit in a bit string. i is the index of the bit to clear, the first bit having index 0. i must be less than the bit string's size. It is not possible to change the size of an existing bit string.
bs | Pointer to the bit string. |
i | Index of the bit to clear (starting from 0). |
int BsClearAll | ( | BitString_t * | bs | ) |
Clear a bit string This function clears all bits in a bit string.
int BsCompare | ( | const BitString_t * | a, |
const BitString_t * | b | ||
) |
Compare two bit strings.
a | First bit string. |
b | Second bit string. |
BitString_t* BsCopy | ( | BitString_t * | dest, |
const BitString_t * | src | ||
) |
Copy a bit string.
dest | Destination bit string. |
src | Source bit string. |
BitString_t* BsDup | ( | const BitString_t * | src | ) |
Duplicate a bit string.
Returns an independent copy of the argument, or 0 on error.
int BsFree | ( | BitString_t * | bs | ) |
Free a bit string.
This function frees a bit string, releasing all associated memory.
int BsIntersectionCount | ( | const BitString_t * | a, |
const BitString_t * | b | ||
) |
Intersection count.
This function calculates the cardinality of the intersection of two bit strings, i.e., the number of bits that are set in both a and b. The arguments must be bit strings of the same size.
int BsIsSub | ( | const BitString_t * | a, |
const BitString_t * | b | ||
) |
Bit string incidence relation.
This function returns 1 if and only if every bit which is set in a is also set in b. Both bit strings must have the same size.
int BsIsValid | ( | const BitString_t * | bs | ) |
Check if a bit string is valid.
This function checks if its argument, is a pointer to a valid bit string. If the bit string is o.k., the function returns 1. Otherwise, an error is signaled and, if the error handler does not terminate the program, the function returns 0.
bs | Bit string to check. |
bs
is a valid bit string, 0 otherwise. int BsMinus | ( | BitString_t * | dest, |
const BitString_t * | src | ||
) |
Difference of two bit strings.
This function computes the (set theoretical) difference of two bit strings, i.e., a bit in the result is set if and only if it is set in dest but not in src. The result is stored in dest and overwrites the previous value. The arguments must be bit strings of the same size.
int BsOr | ( | BitString_t * | dest, |
const BitString_t * | src | ||
) |
Union of two bit strings.
This function computes the union of two bit strings, i.e., the bitwise logical "or". The result is stored in dest and overwrites the previous value. Both bit strings must have the same size.
void BsPrint | ( | const char * | name, |
const BitString_t * | bs | ||
) |
Print a bit string on stdout.
This function writes a bit string in readable format, i.e., as a sequence of 0's and 1's, to stdout.
name | Name to print before the matrix, or 0. |
bs | The bit string. |
BitString_t* BsRead | ( | FILE * | f | ) |
Read a bit string from a file.
f | File to read from. Must be open for reading. |
int BsSet | ( | BitString_t * | bs, |
int | i | ||
) |
Set one bit in a bit string.
This function sets a single bit in a bit string. i is the index of the bit to set, the first bit having index 0. i must be less than the bit string's size. It is not possible to change the size of an existing bit string.
bs | Pointer to the bit string. |
i | Index of the bit to set (starting from 0). |
int BsTest | ( | const BitString_t * | bs, |
int | i | ||
) |
Test a bit in a bit string.
bs | Pointer to the bit string. |
i | Index of the bit to test (starting from 0). |
int BsWrite | ( | BitString_t * | bs, |
FILE * | f | ||
) |
Write a bit string to a file.
bs | The bit string. |
f | File to write to. Must be open for writing. |