lib/third_party/tracing/base/sorted_array_utils.js
function iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal,
                                            hiVal, cb) {
    if (ary.length == 0)
      return;

    if (loVal > hiVal) return;

    var i = findLowIndexInSortedArray(ary, mapLoFn, loVal);
    if (i == -1) {
      return;
    }
    if (i > 0) {
      var hi = mapLoFn(ary[i - 1]) + mapWidthFn(ary[i - 1], i - 1);
      if (hi >= loVal) {
        cb(ary[i - 1], i - 1);
      }
    }
    if (i == ary.length) {
      return;
    }

    for (var n = ary.length; i < n; i++) {
      var lo = mapLoFn(ary[i]);
      if (lo >= hiVal)
        break;
      cb(ary[i], i);
    }
  }
function iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal,
                                            hiVal, cb) {
    if (ary.length == 0)
      return;

    if (loVal > hiVal) return;

    var i = findLowIndexInSortedArray(ary, mapLoFn, loVal);
    if (i == -1) {
      return;
    }
    if (i > 0) {
      var hi = mapLoFn(ary[i - 1]) + mapWidthFn(ary[i - 1], i - 1);
      if (hi >= loVal) {
        cb(ary[i - 1], i - 1);
      }
    }
    if (i == ary.length) {
      return;
    }

    for (var n = ary.length; i < n; i++) {
      var lo = mapLoFn(ary[i]);
      if (lo >= hiVal)
        break;
      cb(ary[i], i);
    }
  }
function iterateOverIntersectingIntervals ( ary , mapLoFn , mapWidthFn , loVal , hiVal , cb ) { if ( ary . length == 0 ) return ; if ( loVal > hiVal ) return ; var i = findLowIndexInSortedArray ( ary , mapLoFn , loVal ) ; if ( i == - 1 ) { return ; } if ( i > 0 ) { var hi = mapLoFn ( ary [ i - 1 ] ) + mapWidthFn ( ary [ i - 1 ] , i - 1 ) ; if ( hi >= loVal ) { cb ( ary [ i - 1 ] , i - 1 ) ; } } if ( i == ary . length ) { return ; } for ( var n = ary . length ; i < n ; i ++ ) { var lo = mapLoFn ( ary [ i ] ) ; if ( lo >= hiVal ) break ; cb ( ary [ i ] , i ) ; } }
Calls cb for all intervals in the implicit array of intervals
defnied by ary, mapLoFn and mapHiFn that intersect the range
[loVal,hiVal)

This function uses the same scheme as findLowIndexInSortedArray
to define the intervals. The same restrictions on sortedness and
non-overlappingness apply.

@param {Array} ary An array of objects that can be converted into sorted
nonoverlapping ranges [x,y) using the mapLoFn and mapWidth.
@param {function():*} mapLoFn Callback that produces the low value for the
interval represented by an element in the array.
@param {function():*} mapWidthFn Callback that produces the width for the
interval represented by an element in the array.
@param {number} loVal The low value for the search, inclusive.
@param {number} hiVal The high value for the search, non inclusive.
@param {function():*} cb The function to run for intersecting intervals.
Calls cb for all intervals in the implicit array of intervals defnied by ary mapLoFn and mapHiFn that intersect the range [ loVal hiVal )