public static Section CreateSection(int maxValue, BitVector64.Section previous) { if (maxValue < 1) { throw new ArgumentException("maxValue"); } int bit = HighestSetBit(maxValue) + 1; int mask = (1 << bit) - 1; int offset = previous.Offset + NumberOfSetBits(previous.Mask); if (offset > 64) { throw new ArgumentException("Sections cannot exceed 64 bits in total"); } return(new Section((short)mask, (short)offset)); }
public long this[BitVector64.Section section] { get { return((data >> section.Offset) & section.Mask); } set { if (value < 0) { throw new ArgumentException("Section can't hold negative values"); } if (value > section.Mask) { throw new ArgumentException("Value too large to fit in section"); } this.data &= ~(section.Mask << section.Offset); this.data |= (value << section.Offset); } }