/// <summary> /// Creates a RLEBitset from an array of indices. /// Each value in the input array represents the position (i.e. index) of a 1. /// </summary> /// <param name="indices">an array of integers representing the positions of 1's</param> /// <returns>an RLEBitset</returns> public static IBitset CreateFrom(int[] indices) { int capacity = 0; if (indices.Length > 0) { capacity = indices.Max() + 1; } return(RLEBitset.CreateFrom(indices, capacity)); }
/// <summary> /// Sets the bit at a specific position in the IBitset to the specified value. /// </summary> /// <param name="index">The zero-based index of the bit to set.</param> /// <param name="value">The Boolean value to assign to the bit.</param> public void Set(int index, bool value) { int[] tmpIndices = { index }; IBitset other = RLEBitset.CreateFrom(tmpIndices, this.length); if (value) { OrWith(other); } else { DifferenceWith(other); } }