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.
More...
|
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) |
|
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) |
|
int | BsClear (BitString_t *bs, int i) |
|
int | BsTest (const BitString_t *bs, int i) |
|
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.
◆ BsAlloc()
Create a bit string.
This function creates a new bit string of the specified size. The new bit string is filled with zeros.
- See also
- BsFree()
- Parameters
-
size | Size of the bit string. |
- Returns
- Pointer to the new bit string, or NULL on error.
◆ BsAnd()
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.
- Returns
- 0 on success, -1 on error.
◆ BsClear()
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.
- See also
- BsSet(BitString_t*,int)
- Parameters
-
bs | Pointer to the bit string. |
i | Index of the bit to clear (starting from 0). |
- Returns
- 0 on success, -1 on error.
◆ BsClearAll()
Clear a bit string This function clears all bits in a bit string.
- Returns
- 0 on success, -1 on error.
◆ BsCompare()
Compare two bit strings.
- Parameters
-
a | First bit string. |
b | Second bit string. |
- Returns
- 0 if the bit strings are equal. Otherwise the return value is different from zero.
◆ BsCopy()
Copy a bit string.
- See also
- BsDup(BitString_t const *)
- Parameters
-
dest | Destination bit string. |
src | Source bit string. |
- Returns
- dest on success, 0 on error.
◆ BsDup()
Duplicate a bit string.
Returns an independent copy of the argument, or 0 on error.
◆ BsFree()
Free a bit string. This function frees a bit string, releasing all associated memory.
- See also
- BsAlloc()
◆ BsIntersectionCount()
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.
- Returns
- Number of bits in the intersection of a and b, or -1 on error.
◆ BsIsSub()
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.
- Returns
- 1 if a⊆b, 0 if a⊈b, -1 on error.
◆ BsIsValid()
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.
- Parameters
-
- Returns
- 1 if
bs
is a valid bit string, 0 otherwise.
◆ BsMinus()
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.
- Returns
- 0 on success, -1 on error.
◆ BsOr()
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.
- Returns
- 0 on success, -1 on error.
◆ BsPrint()
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.
- Parameters
-
name | Name to print before the matrix, or 0. |
bs | The bit string. |
◆ BsRead()
Read a bit string from a file.
- Parameters
-
f | File to read from. Must be open for reading. |
- Returns
- The bit string, 0 on error.
◆ BsSet()
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.
- See also
- BsClear(BitString_t*,int)
- Parameters
-
bs | Pointer to the bit string. |
i | Index of the bit to set (starting from 0). |
- Returns
- 0 on success, -1 on error.
◆ BsTest()
Test a bit in a bit string.
- Parameters
-
bs | Pointer to the bit string. |
i | Index of the bit to test (starting from 0). |
- Returns
- 1 if the bit is set, 0 otherwise.
◆ BsWrite()
Write a bit string to a file.
- Parameters
-
bs | The bit string. |
f | File to write to. Must be open for writing. |
- Returns
- 0 on success, -1 on error.