先贴一段吧,以前看到的那两个暂时没找到,下面一个是位存储中的一段,重载[]用来判断某位是1还是0
inline bool operator[](unsigned int iPos)
{
if(iPos >= m_nSize)
{
return false;
}
int m = iPos>>3;
int n = iPos - (m<<3);
unsigned char data = *((unsigned char *)(m_pData+m));
return ((data>>n)&0x01);
}
void swap( int& a, int& b ) { if ( a == b ) return; a ^= b; b ^= a; a ^= b; }