示例#1
0
        public IBitset Difference(IBitset otherSet)
        {
            UncompressedBitArray workset = null;

            if (otherSet is UncompressedBitArray)
            {
                workset = (UncompressedBitArray)otherSet;
            }
            else
            {
                throw new InvalidOperationException("otherSet is not an UncompressedBitArray");
            }

            UncompressedBitArray newArray = (UncompressedBitArray)this.Clone();

            for (int i = 0; i < workset._Array.Length; i++)
            {
                if (workset._Array[i] && i < this.Length())
                {
                    newArray.Set(i, false);
                }
            }

            return(newArray);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            //
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //

            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            else
            {
                UncompressedBitArray compare = (UncompressedBitArray)obj;
                bool answer = (this.Length() == compare.Length());
                if (answer)
                {
                    for (int i = 0; i < Length(); i++)
                    {
                        if (this._Array.Get(i) != compare._Array.Get(i))
                        {
                            answer = false;
                        }
                    }
                }
                return(answer);
            }
        }
示例#3
0
        public IBitset Not()
        {
            var newSet = new UncompressedBitArray();

            newSet._Array = _Array.Not();

            return(newSet);
        }
示例#4
0
        /// <summary>
        /// Returns a new bitset that consists of all elements that are not
        /// in this bitset.
        /// </summary>
        /// <returns>The new bitset</returns>
        public IBitset Not()
        {
            UncompressedBitArray newSet = new UncompressedBitArray();

            newSet.array = array.Not();

            return(newSet);
        }
示例#5
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            UncompressedBitArray compare = (UncompressedBitArray)obj;
            bool equalLength             = (this.Length == compare.Length);

            if (equalLength)
            {
                for (int i = 0; i < this.Length; i++)
                {
                    if (this.array.Get(i) != compare.array.Get(i))
                    {
                        equalLength = false;
                    }
                }
            }
            return(equalLength);
        }
        /// <summary>
        /// Returns a new bitset that consists of all elements that are not
        /// in this bitset.
        /// </summary>
        /// <returns>The new bitset</returns>
        public IBitset Not()
        {
            var newSet = new UncompressedBitArray();
            newSet.array = array.Not();

            return newSet;
        }
 public UncompressedBitArray(UncompressedBitArray copy)
 {
     array = new BitArray(copy.array);
 }
示例#8
0
 public UncompressedBitArray(UncompressedBitArray copy)
 {
     _Array = new BitArray(copy._Array);
 }