/// <summary> /// Add to the current bitmap all integers in [rangeStart,rangeEnd). /// </summary> /// <param name="rangeStart">inclusive beginning of range</param> /// <param name="rangeEnd">exclusive ending of range</param> public override Container Add(ushort rangeStart, ushort rangeEnd) { int indexstart = Utility.UnsignedBinarySearch(Content, 0, Cardinality, rangeStart); if (indexstart < 0) { indexstart = -indexstart - 1; } int indexend = Utility.UnsignedBinarySearch(Content, 0, Cardinality, (ushort)(rangeEnd - 1)); if (indexend < 0) { indexend = -indexend - 1; } else { indexend++; } int rangelength = rangeEnd - rangeStart; int newcardinality = indexstart + (Cardinality - indexend) + rangelength; if (newcardinality > DEFAULT_MAX_SIZE) { BitsetContainer a = this.ToBitsetContainer(); return(a.Add(rangeStart, rangeEnd)); } if (newcardinality >= this.Content.Length) { IncreaseCapacity(newcardinality); } Array.Copy(Content, indexend, this.Content, indexstart + rangelength, Cardinality - indexend); for (int k = 0; k < rangelength; ++k) { this.Content[k + indexstart] = (ushort)(rangeStart + k); } this.Cardinality = newcardinality; return(this); }