1 #ifndef _WDL_BITFIELD_H_
2 #define _WDL_BITFIELD_H_
6 class WDL_BitField
// ultra simple bit field
9 bool SetSize(int sz
) // clears state
11 void *b
=m_hb
.ResizeOK((sz
+7)/8);
12 if (b
) memset(b
,0,m_hb
.GetSize());
15 int GetApproxSize() const { return m_hb
.GetSize()*8; } // may return slightly greater than the size set
17 bool IsSet(unsigned int idx
) const
19 const unsigned char mask
= 1<<(idx
&7);
21 return idx
< m_hb
.GetSize() && (((unsigned char *)m_hb
.Get())[idx
]&mask
);
23 void Set(unsigned int idx
)
25 const unsigned char mask
= 1<<(idx
&7);
27 if (idx
< m_hb
.GetSize()) ((unsigned char *)m_hb
.Get())[idx
] |= mask
;
34 #endif //_WDL_BITFIELD_H_