CreateFrom() публичный статический Метод

Creates a RLEBitset from a BitArray.
public static CreateFrom ( BitArray bits ) : IBitset
bits System.Collections.BitArray a BitArray
Результат IBitset
Пример #1
0
        /// <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));
        }
Пример #2
0
        /// <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);
            }
        }