Example #1
0
// Candidate funciton for bs class
bool BitKey::isSubset(const BitKey & that) const
{
  bool result = true;
  const uint32_t * mydata = cDataPtr();
  const uint32_t * yodata = that.cDataPtr();
  uint32_t mysize = getWordSize(iv_Capacity);
  uint32_t yosize = getWordSize(that.iv_Capacity);
  uint32_t smsize = (yosize < mysize)? yosize : mysize;
  // size can be non-zero with no bits on - so if that has no bits than use
  // operator==
  BitKey zero;
  // only true if both are empty - eg not bits on"
  if(that == zero) result = operator==(that);
  // if yosize <= mysize than just match smallest amount of data
  // if yozize > mysize than extra yodata must be zero
  for(uint32_t i = 0; (i < smsize) && (result == true); ++i,++mydata,++yodata)
  {
    result = (*mydata & *yodata) == *yodata;
  }
  if(result &&  (yosize > mysize))
  {
    for(yosize -= mysize; yosize != 0 && result; --yosize, ++yodata)
    {
      result = *yodata == 0x00000000;
    }
  }

  return result;
}
Example #2
0
bool BitKey::operator==(const BitKey & that) const
{
  bool result = true;
  const uint32_t * mydata = cDataPtr();
  const uint32_t * yodata = that.cDataPtr();
  uint32_t mysize = getWordSize(iv_Capacity);
  uint32_t yosize = getWordSize(that.iv_Capacity);
  uint32_t smsize = (yosize < mysize)? yosize : mysize;

  // If size is different than the extra must be zero
  for(uint32_t i = 0; (i < smsize) && (result == true); ++i,++mydata,++yodata)
  {
    result = (*mydata == *yodata);
  }
  if(result &&  (yosize > mysize))
  {
    for(yosize -= mysize; yosize != 0 && result; --yosize, ++yodata)
    {
      result = *yodata == 0x00000000;
    }
  }
  else if (result && (mysize > yosize))
  {
    for(mysize -= yosize; mysize != 0 && result; --mysize, ++mydata)
    {
      result = *mydata == 0x00000000;
    }
  }

  return result;
}
Example #3
0
void BitKey::removeBits(const BitKey & i_bk)
{
  BitString mybs(iv_Capacity,(CPU_WORD *)DataPtr());
  const BitString yobs(i_bk.iv_Capacity,(CPU_WORD *)i_bk.cDataPtr());
  mybs.Mask(yobs);
}