merge(references) {
    if (goog.DEBUG) {
      shaka.media.SegmentIndex.assertCorrectReferences_(references);
    }
    if (this.immutable_) {
      return;
    }

    if (!references.length) {
      return;
    }

    // Partial segments are used for live edge, and should be removed when they
    // get older. Remove the old SegmentReferences after the first new
    // reference's start time.
    // Use times rounded to the millisecond for filtering purposes, so that
    // tiny rounding errors will not result in duplicate segments in the index.
    const firstStartTime = Math.round(references[0].startTime * 1000) / 1000;
    this.references = this.references.filter((r) => {
      return (Math.round(r.startTime * 1000) / 1000) < firstStartTime;
    });

    this.references.push(...references);

    if (goog.DEBUG) {
      shaka.media.SegmentIndex.assertCorrectReferences_(this.references);
    }
  }
Merges the given SegmentReferences.  Supports extending the original
references only.  Will replace old references with equivalent new ones, and
keep any unique old ones.

Used, for example, by the DASH and HLS parser, where manifests may not list
all available references, so we must keep available references in memory to
fill the availability window.

@param {!Array<!shaka.media.SegmentReference>} references The list of
  SegmentReferences, which must be sorted first by their start times
  (ascending) and second by their end times (ascending).