libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_bit_view.h File Reference

Go to the source code of this file.

Data Structures

struct  GblBitView
 

Macros

#define GBL_BIT_VIEW_BPW
 
#define GBL_BIT_VIEW_BYTES(bits)
 
#define GBL_BIT_VIEW_WORDS(bits)
 

Functions

GblBitViewGblBitView_fromBuffer (GblBitView *pSelf, void *pBuffer, size_t bitCount, size_t offset)
 
GblBitViewGblBitView_fromView (GblBitView *pSelf, const GblBitView *pView, size_t count, size_t offset)
 
const char * GblBitView_string (const GblBitView *pSelf, GblStringBuffer *pBuffer, size_t index, size_t count)
 
uint64_t GblBitView_uint64 (const GblBitView *pSelf, size_t index, size_t count)
 
GblBitViewGblBitView_setString (GblBitView *pSelf, const char *pString, size_t index, size_t count)
 
GblBitViewGblBitView_setUint64 (GblBitView *pSelf, uint64_t value, size_t index, size_t count)
 
size_t GblBitView_bytes (const GblBitView *pSelf)
 
size_t GblBitView_words (const GblBitView *pSelf)
 
GblBool GblBitView_at (const GblBitView *pSelf, size_t index)
 
size_t GblBitView_count (const GblBitView *pSelf, size_t index, size_t count)
 
GblBool GblBitView_any (const GblBitView *pSelf, size_t index, size_t count)
 
GblBool GblBitView_all (const GblBitView *pSelf, size_t index, size_t count)
 
GblBool GblBitView_none (const GblBitView *pSelf, size_t index, size_t count)
 
GblBitViewGblBitView_assign (GblBitView *pSelf, GblBool value, size_t index, size_t count)
 
GblBitViewGblBitView_set (GblBitView *pSelf, size_t index, size_t count)
 
GblBitViewGblBitView_reset (GblBitView *pSelf, size_t index, size_t count)
 
GblBitViewGblBitView_flip (GblBitView *pSelf, size_t index, size_t count)
 
GblBitViewGblBitView_rotate (GblBitView *pSelf, ptrdiff_t n, size_t offset, size_t count)
 
GblBitViewGblBitView_shiftLeft (GblBitView *pSelf, const GblBitView *pSrc, size_t amount)
 
GblBitViewGblBitView_shiftRight (GblBitView *pSelf, const GblBitView *pSrc, size_t amount)
 

Detailed Description

GblBitView bitvector view container and related functions.

Mutable view to a field of bits within some block of memory.

GblBitView is a view-based container, which does not own, but simply references, an existing field of bits within another buffer. It provides a comparable API to that of a "BitArray," "BitVector," "BitMap," or "BitSet," as they're often known.

GblBitView allows you to conveniently refer a range of bits as though they were a regular array, allowing you to perform operations on them individually. Certain operations such as count, set, reset, and flip, are implemented with optimized algorithms that operate either per-word or per-byte, rather than requiring iteration over every bit.

Note
Even though GblBitView is a view, which does not "own" the memory it is backed by, certain function overloads are able to create alloca()-backed stack memory on-the-fly to associate with the view, so you don't have to provide a backing buffer for it.
See also
GblByteArray
Todo:
  • finish implementation
  • decide on API for bitwise ops against others
Author
Falco Girgis

Definition in file gimbal_bit_view.h.

Macro Definition Documentation

◆ GBL_BIT_VIEW_BPW

#define GBL_BIT_VIEW_BPW

Definition at line 14 of file gimbal_bit_view.h.

◆ GBL_BIT_VIEW_BYTES

#define GBL_BIT_VIEW_BYTES (   bits)

Definition at line 15 of file gimbal_bit_view.h.

◆ GBL_BIT_VIEW_WORDS

#define GBL_BIT_VIEW_WORDS (   bits)

Definition at line 16 of file gimbal_bit_view.h.