/*---------------------------------------------------------------------------------------------------------------- Extensions to the Rangy Range object
336915
function createRangeBoundaryMover(isStart, collapse) {
        /*
         Unit can be "character" or "word"
         Options:

         - includeTrailingSpace
         - wordRegex
         - tokenizer
         - collapseSpaceBeforeLineBreak
         */
        return createEntryPointFunction(
            function(session, unit, count, moveOptions) {
                if (typeof count == UNDEF) {
                    count = unit;
                    unit = CHARACTER;
                }
                moveOptions = createNestedOptions(moveOptions, defaultMoveOptions);
                log.debug("** moving boundary. start: " + isStart + ", unit: " + unit + ", count: " + count);

                var boundaryIsStart = isStart;
                if (collapse) {
                    boundaryIsStart = (count >= 0);
                    this.collapse(!boundaryIsStart);
                }
                var moveResult = movePositionBy(session.getRangeBoundaryPosition(this, boundaryIsStart), unit, count, moveOptions.characterOptions, moveOptions.wordOptions);
                var newPos = moveResult.position;
                this[boundaryIsStart ? "setStart" : "setEnd"](newPos.node, newPos.offset);
                log.debug("*** MOVED " + moveResult.unitsMoved, newPos.inspect());
                return moveResult.unitsMoved;
            }
        );
    }
1267164
TokenRange range(Node begin, JavaToken end) {
        if (storeTokens) {
            return new TokenRange(begin.getTokenRange().get().getBegin(), end);
        }
        return null;
    }
886971
public void setRangeList(FSArray v) {
    if (OntRelationMention_Type.featOkTst && ((OntRelationMention_Type)jcasType).casFeat_rangeList == null)
      jcasType.jcas.throwFeatMissing("rangeList", "de.julielab.jules.types.OntRelationMention");
    jcasType.ll_cas.ll_setRefValue(addr, ((OntRelationMention_Type)jcasType).casFeatCode_rangeList, jcasType.ll_cas.ll_getFSRef(v));}
1066101
function expandRangeIgnoreCase(ranges) {
  return K.flatten2(ranges.map(function (r) {
    var parts=K.classify([r,'az','AZ']).map[r];
    return K.flatten2(parts.map(function (p) {
      if (/[a-z]/.test(p)) {
        return [p,p.toUpperCase()];
      } else if (/[A-Z]/.test(p)) {
        return [p,p.toLowerCase()];
      } else return [p];
    }));
  }));
}
502396
@VisibleForTesting
  void rangeSetToByteStringRange(RangeSet<RowKeyWrapper> guavaRangeSet, Query query) {

    for (Range<RowKeyWrapper> guavaRange : guavaRangeSet.asRanges()) {
      // Is it a point?
      if (guavaRange.hasLowerBound() && guavaRange.lowerBoundType() == BoundType.CLOSED
          && guavaRange.hasUpperBound() && guavaRange.upperBoundType() == BoundType.CLOSED
          && guavaRange.lowerEndpoint().equals(guavaRange.upperEndpoint())) {

        query.rowKey(guavaRange.lowerEndpoint().getKey());
      } else {
        ByteStringRange byteRange = ByteStringRange.unbounded();

        // Handle start key
        if (guavaRange.hasLowerBound()) {
          switch (guavaRange.lowerBoundType()) {
            case CLOSED:
              byteRange.startClosed(guavaRange.lowerEndpoint().getKey());
              break;
            case OPEN:
              byteRange.startOpen(guavaRange.lowerEndpoint().getKey());
              break;
            default:
              throw new IllegalArgumentException("Unexpected lower bound type: "
                  + guavaRange.lowerBoundType());
          }
        }

        // handle end key
        if (guavaRange.hasUpperBound()) {
          switch (guavaRange.upperBoundType()) {
            case CLOSED:
              byteRange.endClosed(guavaRange.upperEndpoint().getKey());
              break;
            case OPEN:
              byteRange.endOpen(guavaRange.upperEndpoint().getKey());
              break;
            default:
              throw new IllegalArgumentException("Unexpected upper bound type: " +
                  guavaRange.upperBoundType());
          }
        }
        query.range(byteRange);
      }
    }
  }
134891
public void setRange(Annotation v) {
    if (OntRelationMention_Type.featOkTst && ((OntRelationMention_Type)jcasType).casFeat_range == null)
      jcasType.jcas.throwFeatMissing("range", "de.julielab.jules.types.OntRelationMention");
    jcasType.ll_cas.ll_setRefValue(addr, ((OntRelationMention_Type)jcasType).casFeatCode_range, jcasType.ll_cas.ll_getFSRef(v));}
387416
function combineRanges (ranges) {
  var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart)

  for (var j = 0, i = 1; i < ordered.length; i++) {
    var range = ordered[i]
    var current = ordered[j]

    if (range.start > current.end + 1) {
      // next range
      ordered[++j] = range
    } else if (range.end > current.end) {
      // extend range
      current.end = range.end
      current.index = Math.min(current.index, range.index)
    }
  }

  // trim ordered array
  ordered.length = j + 1

  // generate combined range
  var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex)

  // copy ranges type
  combined.type = ranges.type

  return combined
}
1147307
function normalize(tags, ranges) {
  ranges = ranges === undefined || ranges === null ? asterisk : ranges

  return {tags: cast(tags, 'tag'), ranges: cast(ranges, 'range')}
}
1163049
function zrange(key, start, end, withscores, req) {
  var val = this.getKey(key, req);
  if(val === undefined) return [];
  if(typeof withscores === 'object') {
    req = withscores;
    withscores = null;
  }
  return val.zrange(start, end, withscores);
}
152789
public void setRangesOnIndexedValues(java.util.Collection<ObjectAttributeRange> rangesOnIndexedValues) {
        if (rangesOnIndexedValues == null) {
            this.rangesOnIndexedValues = null;
            return;
        }

        this.rangesOnIndexedValues = new java.util.ArrayList<ObjectAttributeRange>(rangesOnIndexedValues);
    }
812542
private Range<RowKeyWrapper> rowRangeToRange(RowRange btRange) {
    final BoundType startBound;
    final ByteString startKey;

    switch (btRange.getStartKeyCase()) {
      case START_KEY_OPEN:
        startBound = BoundType.OPEN;
        startKey = btRange.getStartKeyOpen();
        break;
      case START_KEY_CLOSED:
        startBound = BoundType.CLOSED;
        startKey = btRange.getStartKeyClosed();
        break;
      case STARTKEY_NOT_SET:
        startBound = BoundType.CLOSED;
        startKey = ByteString.EMPTY;
        break;
      default:
        throw new IllegalArgumentException("Unexpected start key case: " +
            btRange.getStartKeyCase());
    }

    final BoundType endBound;
    final ByteString endKey;
    switch (btRange.getEndKeyCase()) {
      case END_KEY_OPEN:
        endBound = BoundType.OPEN;
        endKey = btRange.getEndKeyOpen();
        break;
      case END_KEY_CLOSED:
        endBound = BoundType.CLOSED;
        endKey = btRange.getEndKeyClosed();
        break;
      case ENDKEY_NOT_SET:
        endBound = BoundType.OPEN;
        endKey = ByteString.EMPTY;
        break;
      default:
        throw new IllegalArgumentException("Unexpected end key case: " + btRange.getEndKeyCase());
    }

    return boundedRange(startBound, startKey, endBound, endKey);
  }
211137
def rangify(number_list):
    """"""
    if not number_list:
        return number_list

    ranges = []

    range_start = prev_num = number_list[0]
    for num in number_list[1:]:
        if num != (prev_num + 1):
            ranges.append((range_start, prev_num))
            range_start = num
        prev_num = num

    ranges.append((range_start, prev_num))
    return ranges
710140
private Object[] buildFromRange(int offset, int keyLength, boolean isLeaf, boolean isExtra)
    {
        // if keyLength is 0, we didn't copy anything from the original, which means we didn't
        // modify any of the range owned by it, so can simply return it as is
        if (keyLength == 0)
            return copyFrom;

        Object[] a;
        if (isLeaf)
        {
            a = new Object[keyLength + (keyLength & 1)];
            System.arraycopy(buildKeys, offset, a, 0, keyLength);
        }
        else
        {
            a = new Object[1 + (keyLength * 2)];
            System.arraycopy(buildKeys, offset, a, 0, keyLength);
            System.arraycopy(buildChildren, offset, a, keyLength, keyLength + 1);
        }
        if (isExtra)
            updateFunction.allocated(ObjectSizes.sizeOfArray(a));
        else if (a.length != copyFrom.length)
            updateFunction.allocated(ObjectSizes.sizeOfArray(a) -
                                     (copyFrom.length == 0 ? 0 : ObjectSizes.sizeOfArray(copyFrom)));
        return a;
    }
1097370
function rangeIntersectsNode(range, node) {
  if (range.intersectsNode) {
    return range.intersectsNode(node)
  } else {
    return rangesIntersect(range, createRangeFromNode(node))
  }
}
1144597
function(range) {
			if (this.overlap(range)) {
				var start = Math.max(range.start, this.start);
				var end = Math.min(range.end, this.end);
				return new Range(start, end - start);
			}
			
			return null;
		}
489975
public static boolean[] updateRanges(boolean[] range, GrammarRules grammar) {
    boolean[] res = Arrays.copyOf(range, range.length);
    for (GrammarRuleRecord r : grammar) {
      if (0 == r.getRuleNumber()) {
        continue;
      }
      res = updateRanges(res, r.getRuleIntervals());
    }
    return res;
  }
133756
function( domRange ) {
					var cursor,
						walker = new characterWalker( domRange );
					this._.cursors = [];
					do {
						cursor = walker.next();
						if ( cursor.character ) this._.cursors.push( cursor );
					}
					while ( cursor.character );
					this._.rangeLength = this._.cursors.length;
				}