Bit Mask技术

来源:互联网 发布:js array后几个 编辑:程序博客网 时间:2024/05/19 12:39
#define __LEOPARD_BOOK_MAX_BYTES__ (__LEOPARD_BOOK_MAX_ROWS__* __LEOPARD_BOOK_MAX_COLS__)U8 Book_Mask[(((U32)__LEOPARD_BOOK_MAX_BYTES__) / 8) + 1];const S32 book_max_bytes = ((U32)__LEOPARD_BOOK_MAX_BYTES__);#define BOOK_ARRAY_SET_BIT_MASK(_mask, _index)  (_mask[_index / 8] |= (1 << (_index % 8)))#define BOOK_ARRAY_CLEAR_BIT_MASK(_mask, _index)  (_mask[_index / 8] &= ~(1 << (_index % 8)))#define BOOK_ARRAY_IS_BIT_MASK(_mask, _index)  ((_mask[_index / 8] >> (_index & 0x7)) & 0x1)void Hide_Char_By_Index(U8* ItemMask,U32 index){    U16 idx = 0, reminding = 0;    if (index < book_max_bytes)    {        idx = index / 8;        reminding = index - (idx * 8);        *(ItemMask+idx) |= (1 << (7 - reminding));    }}void Unhide_Char_By_Index(U8* ItemMask,U32 index){    U16 idx = 0, reminding = 0;    if (index < book_max_bytes)    {        idx = index / 8;        reminding = index - (idx * 8);        *(ItemMask+idx) &= ~(1 << (7 - reminding));   }}bool Is_Char_Hidden_By_Index(U8* ItemMask,U32 index){    return ((ItemMask[index / 8] >> (index & 0x7)) & 0x1);}

 
原创粉丝点击