SphinxBase  5prealpha
bitarr.h File Reference

An implementation bit array - memory efficient storage for digit int and float data. More...

#include <string.h>
#include <sphinxbase/prim_type.h>
#include <sphinxbase/sphinxbase_export.h>

Go to the source code of this file.

Data Structures

struct  bitarr_mask_s
 Structure that specifies bits required to efficiently store certain data. More...
 
struct  bitarr_address_s
 Structure that stores address of certain value in bit array. More...
 

Typedefs

typedef struct bitarr_mask_s bitarr_mask_t
 Structure that specifies bits required to efficiently store certain data.
 
typedef struct bitarr_address_s bitarr_address_t
 Structure that stores address of certain value in bit array.
 

Functions

SPHINXBASE_EXPORT uint64 bitarr_read_int57 (bitarr_address_t address, uint8 length, uint64 mask)
 Read uint64 value from bit array. More...
 
SPHINXBASE_EXPORT void bitarr_write_int57 (bitarr_address_t address, uint8 length, uint64 value)
 Write specified value into bit array. More...
 
SPHINXBASE_EXPORT uint32 bitarr_read_int25 (bitarr_address_t address, uint8 length, uint32 mask)
 Read uint32 value from bit array. More...
 
SPHINXBASE_EXPORT void bitarr_write_int25 (bitarr_address_t address, uint8 length, uint32 value)
 Write specified value into bit array. More...
 
SPHINXBASE_EXPORT void bitarr_mask_from_max (bitarr_mask_t *bit_mask, uint32 max_value)
 Fills mask for certain int range according to provided max value. More...
 
SPHINXBASE_EXPORT uint8 bitarr_required_bits (uint32 max_value)
 Computes amount of bits required ti store integers upto value provided. More...
 

Detailed Description

An implementation bit array - memory efficient storage for digit int and float data.

Implementation of basic operations of read/write digits consuming as little space as possible.

Definition in file bitarr.h.

Function Documentation

SPHINXBASE_EXPORT void bitarr_mask_from_max ( bitarr_mask_t bit_mask,
uint32  max_value 
)

Fills mask for certain int range according to provided max value.

Parameters
bit_maskmask that is filled
max_valuebigest integer that is going to be stored using this mask

Definition at line 125 of file bitarr.c.

References bitarr_required_bits().

SPHINXBASE_EXPORT uint32 bitarr_read_int25 ( bitarr_address_t  address,
uint8  length,
uint32  mask 
)

Read uint32 value from bit array.

Assumes mask == (1 << length) - 1 where length <= 25

Parameters
addressto read from
lengthnumber of bits for value
maskof read value
Returns
uint32 value that was read

Definition at line 100 of file bitarr.c.

SPHINXBASE_EXPORT uint64 bitarr_read_int57 ( bitarr_address_t  address,
uint8  length,
uint64  mask 
)

Read uint64 value from bit array.

Assumes mask == (1 << length) - 1 where length <= 57

Parameters
addressto read from
lengthnumber of bits for value
maskof read value
Returns
uint64 value that was read

Definition at line 82 of file bitarr.c.

SPHINXBASE_EXPORT uint8 bitarr_required_bits ( uint32  max_value)

Computes amount of bits required ti store integers upto value provided.

Parameters
max_valuebigest integer that going to be stored using this amount of bits
Returns
amount of bits required to store integers from range with maximum provided

Definition at line 131 of file bitarr.c.

Referenced by bitarr_mask_from_max().

SPHINXBASE_EXPORT void bitarr_write_int25 ( bitarr_address_t  address,
uint8  length,
uint32  value 
)

Write specified value into bit array.

Assumes value < (1 << length) and length <= 25. Assumes the memory is zero initially.

Parameters
addressin bit array ti write to
lengthamount of active bytes in value to write
valueinteger to write

Definition at line 112 of file bitarr.c.

SPHINXBASE_EXPORT void bitarr_write_int57 ( bitarr_address_t  address,
uint8  length,
uint64  value 
)

Write specified value into bit array.

Assumes value < (1 << length) and length <= 57. Assumes the memory is zero initially.

Parameters
addressto write to
lengthamount of active bytes in value to write
valueinteger to write

Definition at line 87 of file bitarr.c.