BitsetsNET.RLEBitset.Merge C# (CSharp) Method

Merge() private method

private Merge ( Run &current, Run &next, bool shouldInsert, int index ) : bool
current Run
next Run
shouldInsert bool
index int
return bool
        private bool Merge(ref Run current, ref Run next, bool shouldInsert, int index)
        {
            bool mergedOverlappingIntervalIndicator = false;
            if (TryCreateUnion(current, next, ref current))
            {
                //union made. Replace the current in place
                this.runArray[index] = current;
                mergedOverlappingIntervalIndicator = true;
            }
            else
            {
                current = next;
                if (shouldInsert)
                {
                    this.runArray.Insert(index + 1, next);
                }
            }

            return mergedOverlappingIntervalIndicator;
        }