Interface: tos.lib.Deluge.BitVecUtils

interface BitVecUtils

Provides generic methods for manipulating bit vectors.

Author:
Jonathan Hui <jwhui@cs.berkeley.edu>

Commands
command result_t countOnes(uint16_t *pResult, uint8_t *bitVec, uint16_t length) Counts the number of '1' bits in a bit vector.
command result_t indexOf(uint16_t *pResult, uint16_t fromIndex, uint8_t *bitVec, uint16_t length) Locates the index of the first '1' bit in a bit vector.
command void printBitVec(char *buf, uint8_t *bitVec, uint16_t length) Generates an ASCII representation of the bit vector.

Commands - Details

countOnes

command result_t countOnes(uint16_t *pResult, uint8_t *bitVec, uint16_t length)

Counts the number of '1' bits in a bit vector.

Parameters:
result - the number of '1' bits
bitVec - the bit vector
length - the length of the bit vector in bits
Returns:
SUCCESS if the operation completed successfully; FAIL otherwise.

indexOf

command result_t indexOf(uint16_t *pResult, uint16_t fromIndex, uint8_t *bitVec, uint16_t length)

Locates the index of the first '1' bit in a bit vector.

Parameters:
result - the location of the '1' bit
fromIndex - the index to start search for '1' bit
bitVec - the bit vector
length - the length of the bit vector in bits
Returns:
SUCCESS if a '1' bit was found; FAIL otherwise.

printBitVec

command void printBitVec(char *buf, uint8_t *bitVec, uint16_t length)

Generates an ASCII representation of the bit vector.

Parameters:
buf - the character array to place the ASCII string
bitVec - the bit vector
length - the length of the bit vector in bits