BitsetsNET.UncompressedBitArray.Difference C# (CSharp) Method

Difference() public method

Creates a new IBitSet that has the members of this BitSet that are not members of the other bitset
public Difference ( IBitset otherSet ) : IBitset
otherSet IBitset The other bitset
return IBitset
        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;
        }