diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/bfc/bitlist.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Wasabi/bfc/bitlist.h')
-rw-r--r-- | Src/Wasabi/bfc/bitlist.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Src/Wasabi/bfc/bitlist.h b/Src/Wasabi/bfc/bitlist.h new file mode 100644 index 00000000..b73dcd19 --- /dev/null +++ b/Src/Wasabi/bfc/bitlist.h @@ -0,0 +1,41 @@ +#ifndef _BITLIST_H +#define _BITLIST_H + +#include "memblock.h" + +class BitList { +public: + BitList(unsigned int size=0) { + setSize(size); + } + + int getitem(int n) const { + if (n < 0 || n >= m_size) return 0; + return (m_list[n>>3]>>(n&7))&1; + } + void setitem(int n, int v) { + if (n >= 0 && n < m_size) { + int lv=1<<(n&7); + if (v) m_list[n>>3]|=lv; + else m_list[n>>3]&=~lv; + } + } + + int operator[](int n) const { return getitem(n); } + + int getSize() const { // in bits + return m_size; + } + void setSize(unsigned int newsize) { + m_list.setSize((newsize+7)>>3); + m_size = newsize; + } + + int getsize() const { return m_size; } + +private: + MemBlock< uint8_t> m_list; + int m_size; +}; + +#endif |