BitsetsNET.RLEBitset.AddRunToRLE C# (CSharp) Method

AddRunToRLE() private method

Helper function for Or operations. Adds the given run to the run-array by. Either: a) merges it with the previous run if overlap with previous in array b) adds it as next run if no overlap with previous in array
private AddRunToRLE ( RLEBitset &currRLE, Run runToAdd ) : void
currRLE RLEBitset the RLE to be modified
runToAdd Run the Run to add
return void
        private void AddRunToRLE(ref RLEBitset currRLE, Run runToAdd)
        {
            Run currRun = new Run();
            if (TryCreateUnion(currRLE.runArray.LastOrDefault(), runToAdd, ref currRun) && currRLE.runArray.Count > 0)
            {
                //there is overlap with the previous run in run-array so we merge this run with the previous in the array.
                int tmpIndx = currRLE.runArray.Count - 1;
                currRLE.runArray[tmpIndx] = currRun;
            }
            else
            {
                //no overlap with previous run in run-array, so we add the overlapping run as is.
                currRLE.runArray.Add(runToAdd);
            }
        }