public Builder Set(int index, bool value) { CheckIndex(index); BitUtility.SetBit(ValueBuffer.Span, index, value); BitUtility.SetBit(ValidityBuffer.Span, index, true); return(this); }
public Builder Toggle(int index) { CheckIndex(index); BitUtility.ToggleBit(ValueBuffer.Span, index); BitUtility.SetBit(ValidityBuffer.Span, index, true); return(this); }
/// <summary> /// Set the bit at a particular index to 1. /// </summary> /// <param name="index">Index of bit to set.</param> /// <returns>Returns the builder (for fluent-style composition).</returns> public BitmapBuilder Set(int index) { CheckIndex(index); bool priorValue = BitUtility.GetBit(Span, index); SetBitCount += priorValue ? 0 : 1; BitUtility.SetBit(Span, index); return(this); }
/// <summary> /// Set the bit at a particular index to a given value. /// </summary> /// <param name="index">Index of bit to set/unset.</param> /// <param name="value">Value of bit.</param> /// <returns>Returns the builder (for fluent-style composition).</returns> public BitmapBuilder Set(int index, bool value) { CheckIndex(index); bool priorValue = BitUtility.GetBit(Span, index); SetBitCount -= priorValue ? 1 : 0; SetBitCount += value ? 1 : 0; BitUtility.SetBit(Span, index, value); return(this); }
/// <summary> /// Swap the bits at two given indices. /// </summary> /// <param name="i">First index.</param> /// <param name="j">Second index.</param> /// <returns>Returns the builder (for fluent-style composition).</returns> public BitmapBuilder Swap(int i, int j) { CheckIndex(i); CheckIndex(j); bool bi = BitUtility.GetBit(Span, i); bool bj = BitUtility.GetBit(Span, j); BitUtility.SetBit(Span, i, bj); BitUtility.SetBit(Span, j, bi); return(this); }
public Builder Append(bool value) { if (Length % 8 == 0) { // append a new byte to the buffer when needed ValueBuffer.Append(0); } BitUtility.SetBit(ValueBuffer.Span, Length, value); Length++; return(this); }
public Builder Swap(int i, int j) { CheckIndex(i); CheckIndex(j); var bi = BitUtility.GetBit(ValueBuffer.Span, i); var bj = BitUtility.GetBit(ValueBuffer.Span, j); BitUtility.SetBit(ValueBuffer.Span, i, bj); BitUtility.SetBit(ValueBuffer.Span, j, bi); return(this); }
/// <summary> /// Append a single bit. /// </summary> /// <param name="value">Bit to append.</param> /// <returns>Returns the builder (for fluent-style composition).</returns> public BitmapBuilder Append(bool value) { if (Length % 8 == 0) { // Append a new byte to the buffer when needed. EnsureAdditionalCapacity(1); } BitUtility.SetBit(Span, Length, value); Length++; SetBitCount += value ? 1 : 0; return(this); }
private Builder NullableAppend(bool?value) { if (Length % 8 == 0) { // append a new byte to the buffer when needed ValueBuffer.Append(0); ValidityBuffer.Append(0); } BitUtility.SetBit(ValueBuffer.Span, Length, value.GetValueOrDefault()); BitUtility.SetBit(ValidityBuffer.Span, Length, value.HasValue); NullCount += value.HasValue ? 0 : 1; Length++; return(this); }
public void Set(int index) { BitUtility.SetBit( Buffer.GetSpan <byte>(), index); }
public Builder Set(int index) { CheckIndex(index); BitUtility.SetBit(ValueBuffer.Span, index); return(this); }