/*
Returns the index of the slice in the timeSlices array, or undefined.
511200
function(timeSlice) {
      var i = tr.b.findLowIndexInSortedArray(
          this.timeSlices,
          function(slice) { return slice.start; },
          timeSlice.start);
      if (this.timeSlices[i] !== timeSlice)
        return undefined;
      return i;
    }
144287
function(arr, num) {
    if (isUndefined(num)) return arr[0];
    if (num < 0) num = 0;
    return arr.slice(0, num);
  }
838909
function(needle) {
        if (arr.indexOf) {
          return arr.indexOf(needle);
        } else {
          for (var i=0, length=arr.length; i<length; i++) {
            if (arr[i] === needle) { return i; }
          }
          return -1;
        }
    }
329447
function fromIndex(a, index) {
    var arr = is.isArguments(a) ? arraySlice.call(a) : a;
    return arraySlice.call(arr, index, arr.length);
}
217434
function(encoded) {
      if (encoded instanceof Array) {
        encoded = encoded.map(function(chunk) {return chunk.replace(/^0x/g, '')}).join('');
      }

      // Each symbol is 4 bits
      var result = [];
      var nextIndex = 0;
      while (nextIndex < encoded.length) {
        var schemaLength = parseInt(encoded.slice(nextIndex, nextIndex + 1 * 2), 16);
        var idLength = parseInt(encoded.slice(nextIndex + (1 + schemaLength) * 2, nextIndex + (1 + schemaLength + 2) * 2), 16);

        var schema = encoded.slice(nextIndex + 1 * 2, nextIndex + (1 + schemaLength) * 2);
        // Convert to string
        schema = hexToString(schema);
        var idHex = encoded.slice(nextIndex + (1 + schemaLength + 2) * 2, nextIndex + (1 + schemaLength + 2 + idLength) * 2);
        var id = schema.match(allowedProtocolsRegExp) ? idHex : hexToString(idHex);
        result.push(schema + ':' + id);

        // Get full cells
        var cellsPerId = Math.ceil((1 + schemaLength + 2 + idLength) / 32);
        nextIndex += cellsPerId * 32 * 2;
      }

      return result;
    }
1187331
function(s) {
                //TODO: validate array length
		//TODO: return unwanted subset as new Px object

                var counts = this.valCounts(),
                multipliers = [];

                _.each(s, function(d, i) {
                    if (d[0] === '*') {
                        s[i] = _.range(0, counts[i] - 1);
                    }
                });

                for (var i = 0, l = counts.length; i < l - 1; i++) {
                    multipliers[i] = _.reduce(counts.slice(i+1), function(a, b) { return a * b; });
                }
                multipliers.push(1);

                for (var j = 0, k = s.length; j < k; j++) {
                    
                    // drop the values
                    this.metadata.VALUES[this.variables()[j]] = 
                        _.filter(this.metadata.VALUES[this.variables()[j]], function(e, m) {
                            return _.indexOf(s[j], m) !== -1;
                        });
                }

                var keepIdxs = [];
                var pattern = function pattern(c,m,w,p) {
                    if (c.length > 1) {
                        p = typeof p !== 'undefined' ? p : 1;
                        var count = c.pop(),
                            multiple = m.pop(),
                            want = w.pop();

                        var patt = _.flatten(_.map(_.range(0, count), function(d) { 
                            return _.include(want, d) ? p : _arrayOfZeroes(multiple);
                        }));

                        pattern(c, m, w, patt);
                    }
                    keepIdxs.push(_.flatten(p));
                };
                pattern(counts,multipliers,s);
                keepIdxs = keepIdxs[0];

                var indices = [];
                _.each(s[0], function(d) {
                    var start = d * multipliers[0];
                    var end = start + multipliers[0];
                    indices.push(_.filter(_.range(start, end), function(d, i) {return keepIdxs[i] === 1;}));
                });
                indices = _.flatten(indices);
                this.data = _.filter(this.data, function(d, i) {return _.indexOf(indices, i) !== -1;});
            }
616924
function (arr) {
      for (var i = 1; i < arr.length; i++) {
        var tmp = arr[i],
          j = i;
        while (arr[j - 1] && parseInt(arr[j - 1].width, 10) > parseInt(tmp.width, 10)) {
          arr[j] = arr[j - 1];
          --j;
        }
        arr[j] = tmp;
      }

      return arr;
    }
114159
def get_true_slice(dims, data_len):
    '''
    
    '''
    rangeLen = non_str_len_no_throw(dims)

    # Get the range qualifier for length
    if isinstance(dims, slice):
        start = get_restricted_index(int(dims.start), data_len) if dims.start != None else dims.start
        stop = get_restricted_index(int(dims.stop), data_len) if dims.stop != None else dims.stop
        step = get_restricted_index(int(dims.step), data_len) if dims.step != None else dims.step
    elif rangeLen > 3:
        raise AttributeError(str(dims)+' length is > 3')
    elif rangeLen == 3:
        start = get_restricted_index(int(dims[0]), data_len) if dims[0] != None else dims[0]
        stop = get_restricted_index(int(dims[1]), data_len) if dims[1] != None else dims[1]
        step = get_restricted_index(int(dims[2]), data_len) if dims[2] != None else dims[2]
    elif rangeLen == 2:
        start = get_restricted_index(int(dims[0]), data_len) if dims[0] != None else dims[0]
        stop = get_restricted_index(int(dims[1]), data_len) if dims[1] != None else dims[1]
        step = None
    elif rangeLen == 1:
        start = get_restricted_index(int(dims[0]), data_len) if dims[0] != None else dims[0]
        stop = get_restricted_index(int(dims[0]), data_len)+1 if dims[0] != None else dims[0]
        step = None
    elif dims != None:
        start = get_restricted_index(int(dims), data_len) if dims != None else dims
        stop = get_restricted_index(int(dims), data_len)+1 if dims != None else dims
        step = None
    else:
        start = None
        stop = None
        step = None

    return slice(start, stop, step)
908344
function(sliceList){
        var _sliceImgPathUrl = [];
        if(sliceList.length > 0){
            for(var y=0;y<sliceList.length;y++){
                _sliceImgPathUrl[y] = _rootPath+"/"+ sliceList[y];
            }
        }
        return _sliceImgPathUrl;
    }
251335
function arrayIndexOf (array, val) {

        // Use native indexOf
        if (Array.prototype.indexOf) {
            return array.indexOf(val);
        }

        // Use loop/if for environments without native indexOf
        var i, len = array.length;
        for (i = 0; i < len; len += 1) {
            if (array[i] === val) {
                return i;
            }
        }
        return -1;

    }
1020005
function(indexes) {
      var isArray;
      isArray = Array.isArray(indexes);
      if (!isArray) {
        indexes = [indexes];
      }
      indexes.forEach(function(index, i) {
        var k, v;
        if (i === 0) {
          indexes = {};
        }
        [k, v] = index.split(' ');
        return indexes[k] = v;
      });
      if (isArray) {
        return indexes;
      } else {
        return indexes[0];
      }
    }
209968
private static int lastIndexOf(Object o, Object[] elements, int index) {
        if (o == null) {
            for (int i = index; i >= 0; i--)
                if (elements[i] == null)
                    return i;
        } else {
            for (int i = index; i >= 0; i--)
                if (o.equals(elements[i]))
                    return i;
        }
        return -1;
    }
1293483
function findIndex (array, predicate) {
  for (let i = 0; i < array.length; i++) {
    if (predicate(array[i])) return i
  }
  return -1
}
268075
function sliceOf(ars, i, parts) {
  return ars.slice(
    Math.floor(i/parts*ars.length),
    Math.floor((i+1)/parts*ars.length));
}
1374834
function _toIndex(it) {
	  if (it === undefined) return 0;
	  var number = _toInteger(it);
	  var length = _toLength(number);
	  if (number !== length) throw RangeError('Wrong length!');
	  return length;
	}
977049
function indexesOf(a, elt) {
  var ret = [], index = 0;
  while ((index = a.indexOf(elt, index)) !== -1) {
    ret.push(index++);
  }
  return ret;
}
1295422
function indexOf(haystack, needle, i) {
    if (!Buffer.isBuffer(needle)) needle = new Buffer(needle);
    if (typeof i === 'undefined') i = 0;
    var l = haystack.length - needle.length + 1;
    while (i<l) {
      var good = true;
      for (var j=0, n=needle.length; j<n; j++) {
        if (haystack[i+j] !== needle[j]) {
          good = false;
          break;
        }
      }
      if (good) return i;
      i++;
    }
    return -1;
  }