BitsetsNET.RLEBitset.Not C# (CSharp) Method

Not() public method

Inverts all the values in the current IBitset, so that elements set to true are changed to false, and elements set to false are changed to true.
public Not ( ) : IBitset
return IBitset
        public IBitset Not()
        {
            RLEBitset rtnVal = new RLEBitset();
            rtnVal.length = this.length;
            if (runArray.Count > 0)
            {
                Run currRun = new Run();

                // handle first run if needed.
                if (runArray[0].StartIndex > 0)
                {
                    currRun.StartIndex = 0;
                    currRun.EndIndex = runArray[0].StartIndex - 1;
                    rtnVal.runArray.Add(currRun);
                    currRun = new Run();
                }

                // handle the middle runs.
                currRun.StartIndex = runArray[0].EndIndex + 1;
                for (int i = 0; i < runArray.Count - 1; i++)
                {
                    currRun.EndIndex = runArray[i + 1].StartIndex - 1;
                    rtnVal.runArray.Add(currRun);
                    currRun = new Run();
                    currRun.StartIndex = runArray[i + 1].EndIndex + 1;
                }

                // handle the last run.
                if (length > currRun.StartIndex)
                {
                    currRun.EndIndex = length - 1;
                    rtnVal.runArray.Add(currRun);
                }

            }
            else
            {
                rtnVal.runArray.Add(new Run(0, length - 1));
            }

            return rtnVal;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Performs the set difference, defined as the set in A and not in B.
        /// </summary>
        /// <param name="otherSet">the other IBitset</param>
        /// <returns>The set difference of this set and the other.</returns>
        public IBitset Difference(IBitset otherSet)
        {
            RLEBitset otherRLESet = (RLEBitset)otherSet; // cast to an RLEBitset - errors if cannot cast
            IBitset   rtnVal      = And(otherRLESet.Not());

            return(rtnVal);
        }
All Usage Examples Of BitsetsNET.RLEBitset::Not