private void SetValue(ElementInfoIndex index, int value) { ElementInfo info = ElementInfos[(int)index]; int newValue = Storage[info.ByteOffset] & ~(~(-1 << info.BitWidth) << info.BitOffset) | (((value - info.MinValue) & ~(-1 << info.BitWidth)) << info.BitOffset); Storage[info.ByteOffset] = (byte)newValue; }
private bool IsElementValid(ElementInfoIndex index) { ElementInfo info = ElementInfos[(int)index]; int value = GetValue(index); return(value >= info.MinValue && value <= info.MaxValue); }
private int GetValue(ElementInfoIndex index) { ElementInfo info = ElementInfos[(int)index]; return(((Storage[info.ByteOffset] >> info.BitOffset) & ~(-1 << info.BitWidth)) + info.MinValue); }