cp_bstr

Section: libcprops - cp_bstr (3)
Updated: DECEMBER 2011
Index Return to Main Contents
 

NAME

cp_bstr - a bit string implementation

 

INTERFACE

the following is a summary of functions provided by <cprops/bstr.h>.

cp_bstr *cp_bstr_create(int length, unsigned char *bits);
int cp_bstr_destroy(cp_bstr *seq);
int cp_bstr_dup(cp_bstr *seq);
cp_bstr *cp_bstr_cpy(cp_bstr *dst, cp_bstr *src);
cp_bstr *cp_bstr_cat(cp_bstr *head, cp_bstr *tail);
int cp_bstr_shift_left(cp_bstr *seq, int count);
int cp_bstr_cmp(cp_bstr *a, cp_bstr *b, int *pos);
char *cp_bstr_to_string(cp_bstr *seq);
cp_trie *cstr_to_bstr(char *str);
void cp_bstr_dump(cp_bstr *seq);

 

DESCRIPTION

cp_bstr is an arbitrary length bit string implementation, with functions to perform several operations.

cp_bstr_create creates a new bit string with initial capacity large enough to store length bits. If the bits parameter is not NULL the first length bits are copied into the new cp_bstr.

cstr_to_bstr initializes a cp_bstr from a string that looks like "1010101" - intended as a convenience function for debugging

cp_bstr_destroy unallocates the memory associated with a cp_bstr.

cp_bstr_dup creates a copy of the source cp_bstr.

cp_bstr_cpy copies the contents of dst to src extending the memory allocated for dst in the process if necessary.

cp_bstr_cat concatenates the bits in tail onto head extending the memory allocated for head in the process if necessary.

cp_bstr_shift_left shifts bits left by the specified count, resulting in a shorter bit sequence.

cp_bstr_cmp compares bit sequences a and b with strcmp semantics. If pos is not null it is set to the index of the first differing bit. If the sequences are identical to the length they are defined, and pos is not null, it is set to the length of the shorter sequence - e.g. 010 and 0101 are identical to the third bit, hence *pos is set to 3.

cp_bstr_dump print a message with the number of bits and the bit values in human-readable form to stdout

cp_bstr_to_string returns a newly-allocated character string containing the bit values in human- readable form.  

RETURN VALUE

cp_bstr_create returns a new cp_bstr structure or NULL if memory allocation failed.

cp_bstr_dup returns a duplicate of the source cp_bstr structure or NULL if memory allocation failed.

cp_bstr_cpy returns a pointer to the destination bit string structure or NULL if the source sequence was longer than the destination sequence and memory allocation failed.

cp_bstr_cat returns a pointer to the destination bit string structure or NULL if memory allocation failed.

cp_bstr_shift_left returns the new length of the bit string.

cp_bstr_cmp returns > 0 if a > b , < 0 if a < b or 0 if a == b


 

Index

NAME
INTERFACE
DESCRIPTION
RETURN VALUE

This document was created by man2html, using the manual pages.
Time: 23:15:35 GMT, December 05, 2011