When joining with a single range, firstRange would be the same as RangeAt(endIndex - 1) and we would overwrite its offset field before getting its end offset, thus possibly resulting in a wrong joined range size.
Templatized class for managing a set of sorted non-overlapping integer ranges. Merges and splits ranges as necessary.