internal static UInt128 CreateNew(int firstTrue) { var newInstance = new UInt128(); for (int i = firstTrue; i < BITS_PER_TRANSACTION; i++) { newInstance.SetBit(i); } return newInstance; }
/// <summary> /// Returns the MSB most significant bit. /// </summary> public static int LastSetBit(UInt128 value) { if (value == 0) return 0; if(value._second != 0) { return LastSetBit(value._second) + UInt128.BITS_PER_ONE_TRANSACTION_PART; } return LastSetBit(value._first); }
/// <summary> /// Returns the first set bit (FFS), or 0 if no bits are set. /// </summary> public static int FirstSetBit(UInt128 value) { if (value._first != 0) { return FirstSetBit(value._first); } else { return FirstSetBit(value._second) + UInt128.BITS_PER_ONE_TRANSACTION_PART; } }
public Bitmap128(UInt128[] bitmaps, int support) { SequencesCount = bitmaps.Length; _bitmaps = bitmaps; _support = support; }
/// <summary> /// Creates a new bitmap by S-Step with a given item-bitmap. /// </summary> public Bitmap128 CreateNewBySStep(Bitmap128 itemBitmap) { // A new bitmap for S-Step will be create by ANDing transformed sequence-bitmap with item-bitmap. // During creating a new bitmap also counts the support for a new bitmap. var support = 0; var newBitmaps = new UInt128[SequencesCount]; var itemBitmaps = itemBitmap._bitmaps; for (var sid = 0; sid < SequencesCount; ++sid) { if (_bitmaps[sid] == 0) continue; var tid = DeBruijn.FirstSetBit(_bitmaps[sid]); if ((newBitmaps[sid] = (TransformedBitmap[tid] & itemBitmaps[sid])) == 0) continue; ++support; } return support > 0 ? new Bitmap128(newBitmaps, support) : null; }
/// <summary> /// Creates a new bitmap by I-Step with a given item-bitmap. /// </summary> public Bitmap128 CreateNewByIStep(Bitmap128 itemBitmap) { // A new bitmap for I-Step will be create by ANDing sequence-bitmap with item-bitmap. // During creating a new bitmap also counts the support for a new bitmap. var support = 0; var newBitmaps = new UInt128[SequencesCount]; var itemBitmaps = itemBitmap._bitmaps; for (var sid = 0; sid < SequencesCount; ++sid) { if ((newBitmaps[sid] = (_bitmaps[sid] & itemBitmaps[sid])) == 0) continue; ++support; } return support > 0 ? new Bitmap128(newBitmaps, support) : null; }
public bool Equals(UInt128 other) { return other._first == _first && other._second == _second; }