CWB
|
Functions | |
Bitfield | create_bitfield (int nr_of_elements) |
Create a new Bitfield object. More... | |
Bitfield | copy_bitfield (Bitfield source) |
Copies a Bitfield. More... | |
int | destroy_bitfield (Bitfield *bptr) |
Deletes a bitfield object. More... | |
int | set_bit (Bitfield bitfield, int element) |
Sets a bit in a Bitfield to 1. More... | |
int | clear_bit (Bitfield bitfield, int element) |
Sets a bit in a Bitfield to 0 (clears it). More... | |
int | clear_all_bits (Bitfield bitfield) |
Clears an entire Bitfield (ie sets all bits to 0). More... | |
int | set_all_bits (Bitfield bitfield) |
Sets an entire Bitfield (ie sets all bits to 1, all bytes to 0xff). More... | |
int | get_bit (Bitfield bitfield, int element) |
Gets the value of the bit at the specified offset in the Bitfield. More... | |
int | toggle_bit (Bitfield bitfield, int element) |
Switches the value of the specified bit in a Bitfield. More... | |
int | bf_equal (Bitfield bf1, Bitfield bf2) |
Checks two Bitfield objects for equality of all bits. More... | |
int | bf_compare (Bitfield bf1, Bitfield bf2) |
Compares two Bitfield objects. More... | |
int | nr_bits_set (Bitfield bitfield) |
Gets the number of bits set to 1 in the given Bitfield. More... | |
Variables | |
static int | BaseTypeSize = sizeof(BFBaseType) |
Size of the actual field of a Bitfield (in bytes). More... | |
static int | BaseTypeBits = sizeof(BFBaseType) * CHAR_BIT |
Size of the actual field of a Bitfield (in bits). More... | |
Compares two Bitfield objects.
Comparison is done from the start of the bitfield onwards. The Bitfields compared must have the same number of elements!
References BaseTypeBits, BaseTypeSize, BFBuf::bytes, BFBuf::elements, and BFBuf::field.
Checks two Bitfield objects for equality of all bits.
The Bitfields compared must have the same number of elements!
References BaseTypeBits, BaseTypeSize, BFBuf::bytes, BFBuf::elements, and BFBuf::field.
int clear_all_bits | ( | Bitfield | bitfield | ) |
Clears an entire Bitfield (ie sets all bits to 0).
References BFBuf::bytes, BFBuf::field, and BFBuf::nr_bits_set.
Referenced by matchfirstpattern().
int clear_bit | ( | Bitfield | bitfield, |
int | element | ||
) |
Sets a bit in a Bitfield to 0 (clears it).
The number of bits set is decreased by 1 iff the clearing of the specified bit has resulted in a change in the bitfield.
If the offset specified does not exist within this Bitfield, the function returns false (plus an error message is printed). Otherwise it returns true.
bitfield | The Bitfield object to work with. |
element | The offset of the bit to set. |
References BaseTypeBits, BFBuf::field, and BFBuf::nr_bits_set.
Copies a Bitfield.
Creates a new bitfield object whihc is an exact duplicate of the source Bitfield.
source | The Bitfield to copy |
References BFBuf::bytes, create_bitfield(), BFBuf::elements, BFBuf::field, and BFBuf::nr_bits_set.
Bitfield create_bitfield | ( | int | nr_of_elements | ) |
Create a new Bitfield object.
nr_of_elements | The number of bits the field should contain. |
References BaseTypeBits, BaseTypeSize, BFBuf::bytes, cl_malloc(), BFBuf::elements, BFBuf::field, and BFBuf::nr_bits_set.
Referenced by copy_bitfield(), do_delete_lines(), do_delete_lines_num(), do_reduce(), do_StandardQuery(), and matchfirstpattern().
int destroy_bitfield | ( | Bitfield * | bptr | ) |
Deletes a bitfield object.
Referenced by do_delete_lines(), do_delete_lines_num(), do_reduce(), do_StandardQuery(), and matchfirstpattern().
int get_bit | ( | Bitfield | bitfield, |
int | element | ||
) |
Gets the value of the bit at the specified offset in the Bitfield.
bitfield | The Bitfield to work with. |
element | Offset of the desired bit. |
References BaseTypeBits, and BFBuf::field.
Referenced by delete_intervals(), matchfirstpattern(), and RangeSetop().
int nr_bits_set | ( | Bitfield | bitfield | ) |
Gets the number of bits set to 1 in the given Bitfield.
References BFBuf::nr_bits_set.
Referenced by do_delete_lines_num().
int set_all_bits | ( | Bitfield | bitfield | ) |
Sets an entire Bitfield (ie sets all bits to 1, all bytes to 0xff).
References BFBuf::bytes, BFBuf::elements, BFBuf::field, and BFBuf::nr_bits_set.
Referenced by matchfirstpattern().
int set_bit | ( | Bitfield | bitfield, |
int | element | ||
) |
Sets a bit in a Bitfield to 1.
The number of bits set is increased by 1 iff the setting of the specified bit has resulted in a change in the bitfield.
If the offset specified does not exist within this Bitfield, the function returns false (plus an error message is printed). Otherwise it returns true.
bitfield | The Bitfield object to work with. |
element | The offset of the bit to set. |
References BaseTypeBits, BFBuf::field, and BFBuf::nr_bits_set.
Referenced by do_delete_lines(), do_delete_lines_num(), do_reduce(), do_StandardQuery(), and matchfirstpattern().
int toggle_bit | ( | Bitfield | bitfield, |
int | element | ||
) |
Switches the value of the specified bit in a Bitfield.
The number of set bits is either incremented or decremented, as appropriate.
If the offset specified does not exist within this Bitfield, the function returns false (plus an error message is printed). Otherwise it returns true.
bitfield | The Bitfield to work with. |
element | Offset of the bit to flip. |
References BaseTypeBits, BFBuf::field, and BFBuf::nr_bits_set.
Referenced by copy_intervals().
|
static |
Size of the actual field of a Bitfield (in bits).
Referenced by bf_compare(), bf_equal(), clear_bit(), create_bitfield(), get_bit(), set_bit(), and toggle_bit().
|
static |
Size of the actual field of a Bitfield (in bytes).
Referenced by bf_compare(), bf_equal(), and create_bitfield().