Esempio n. 1
0
        public override bool Equals(object obj)
        {
            BV that = obj as BV;

            if (that == null)
            {
                return(false);
            }
            if (this == that)
            {
                return(true);
            }
            if (this.first != that.first)
            {
                return(false);
            }
            if (that.more.Length != this.more.Length)
            {
                return(false);
            }
            for (int i = 0; i < more.Length; i++)
            {
                if (more[i] != that.more[i])
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        public int CompareTo(object obj)
        {
            BV that = obj as BV;

            if (that == null)
            {
                return(1);
            }
            else if (this.more.Length != that.more.Length)
            {
                return(this.more.Length.CompareTo(that.more.Length));
            }
            else
            {
                int k = this.more.Length;
                if (k > 0)
                {
                    int i = k - 1;
                    while (i >= 0)
                    {
                        var comp = this.more[i].CompareTo(that.more[i]);
                        if (comp == 0)
                        {
                            i = i - 1;
                        }
                        else
                        {
                            return(comp);
                        }
                    }
                }
                return(this.first.CompareTo(that.first));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Bitwise NOT
        /// </summary>
        public static BV operator ~(BV x)
        {
            var first_compl = ~x.first;
            var more_compl  = Array.ConvertAll(x.more, n => ~n);
            var compl       = new BV(first_compl, more_compl);

            return(compl);
        }
Esempio n. 4
0
        /// <summary>
        /// Bitwise NOT
        /// </summary>
        public static BV operator ~(BV x)
        {
            var first = ~x.first;

            if (x.nrOfBits < 64)
            {
                first = first & (((ulong)1 << x.nrOfBits) - 1);
            }
            var more        = new ulong[x.more.Length];
            int remNrOfBits = x.nrOfBits;

            for (int i = 0; i < x.more.Length; i++)
            {
                remNrOfBits = x.nrOfBits - 64;
                more[i]     = ~x.more[i];
                if (remNrOfBits < 64)
                {
                    more[i] = more[i] & (((ulong)1 << x.nrOfBits) - 1);
                }
            }
            var notx = new BV(x.nrOfBits, first, more);

            return(notx);
        }