Beispiel #1
0
 // <summary>
 // Dispose of the current enumerator - return it to the Command
 // </summary>
 public void Dispose()
 {
     // Technically, calling GC.SuppressFinalize is not required because the class does not
     // have a finalizer, but it does no harm, protects against the case where a finalizer is added
     // in the future, and prevents an FxCop warning.
     GC.SuppressFinalize(this);
     m_bitArray = null;
     m_command.ReleaseVarVecEnumerator(this);
 }
Beispiel #2
0
        /*=========================================================================
        ** Allocates a new BitVec with the same length and bit values as bits.
        **
        ** Exceptions: ArgumentException if bits == null.
        ** =========================================================================*/
        public BitVec(BitVec bits)
        {
            if (bits == null)
            {
                throw new ArgumentNullException("bits");
            }

            int arrayLength = GetArrayLength(bits.m_length, BitsPerInt32);

            m_array  = ArrayPool.Instance.GetArray(arrayLength);
            m_length = bits.m_length;

            Array.Copy(bits.m_array, m_array, arrayLength);

            _version = bits._version;
        }
Beispiel #3
0
        /*=========================================================================
        ** Returns a reference to the current instance XORed with value.
        **
        ** Exceptions: ArgumentException if value == null or
        **             value.Length != this.Length.
        ** =========================================================================*/
        public BitVec Xor(BitVec value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (Length != value.Length)
            {
                throw new ArgumentException("Arg_ArrayLengthsDiffer");
            }

            int ints = GetArrayLength(m_length, BitsPerInt32);

            for (int i = 0; i < ints; i++)
            {
                m_array[i] ^= value.m_array[i];
            }

            _version++;
            return(this);
        }
Beispiel #4
0
            // <summary>
            // Move to the next position
            // </summary>
            public bool MoveNext()
            {
                int[] values = m_bitArray.m_array;
                m_position++;
                int length = m_bitArray.Length;
                int valuesLen = BitVec.GetArrayLength(length, 32);
                int i = m_position / 32;
                int v = 0, mask = 0;

                if (i < valuesLen)
                {
                    v = values[i];
                    // zero lowest bits that are skipped
                    mask = (~0 << (m_position % 32));

                    v &= mask;

                    if (v != 0)
                    {
                        m_position = (i * 32) + MultiplyDeBruijnBitPosition[((uint)((v & -v) * 0x077CB531U)) >> 27];
                        return(true);
                    }

                    i++;
                    for (; i < valuesLen; i++)
                    {
                        v = values[i];

                        if (v == 0)
                        {
                            continue;
                        }

                        m_position = (i * 32) + MultiplyDeBruijnBitPosition[((uint)((v & -v) * 0x077CB531U)) >> 27];
                        return(true);
                    }
                }
                m_position = length;
                return(false);
            }
Beispiel #5
0
 // <summary>
 // Initialize the enumerator to enumerate over the supplied Vec
 // </summary>
 internal void Init(VarVec vec)
 {
     m_position = -1;
     m_command  = vec.m_command;
     m_bitArray = vec.m_bitVector;
 }
Beispiel #6
0
 internal VarVec(Command command)
 {
     m_bitVector = new BitVec(64);
     m_command   = command;
 }