Package com.baulsupp.kolja.log.util

Examples of com.baulsupp.kolja.log.util.IntRange


   
    int pos = 0;
   
    for (int i = 0; i < height; i++) {
      int newPos = pos + each + (i < leftover ? 1 : 0);
      result.add(new IntRange(pos, newPos));
      pos = newPos;
    }
   
    return result;
  }
View Full Code Here


  private MemoryIntField findEnclosingField(IntRange range) {
    assert (!range.isEmpty());

    for (MemoryIntField currentField : knownFields) {
      IntRange currentRange = currentField.getRange();

      if (currentRange.isCompletelyBefore(range))
        continue;

      if (currentRange.isCompletelyAfter(range))
        return null;

      if (range.isInclusiveSubsetOf(currentRange))
        return currentField;
    }
View Full Code Here

  public MemoryIntField findEnclosingField(int point) {
    assert (point >= 0);

    for (MemoryIntField currentField : knownFields) {
      IntRange currentRange = currentField.getRange();

      if (currentRange.isBefore(point))
        continue;

      if (currentRange.contains(point)) {
        return currentField;
      }

      if (currentRange.isAfter(point))
        return null;
    }

    return null;
  }
View Full Code Here

      throw new IllegalArgumentException("not completely unknown" + newField);
    }

    if (totalRange.isEmpty()) {
      knownFields.add(newField);
      totalRange = new IntRange(newField.getRange());
      return;
    }

    IntRange newRange = newField.getRange();

    if (newRange.getFrom() < totalRange.getFrom())
      totalRange.setFrom(newRange.getFrom());

    ListIterator<MemoryIntField> i = knownFields.listIterator();
    while (i.hasNext()) {
      MemoryIntField currentField = i.next();
      IntRange currentRange = currentField.getRange();

      boolean meets = currentRange.meets(newRange);

      if (!meets && newRange.isCompletelyBefore(currentRange)) {
        knownFields.add(i.previousIndex(), newField);
        return;
      }
View Full Code Here

    int from = range.getFrom();
    int to = range.getTo();

    for (MemoryIntField currentField : knownFields) {
      IntRange currentRange = currentField.getRange();

      // TODO check this doesn't break things
      if (currentRange.isBefore(range.getFrom())) {
        continue;
      }
      if (currentRange.isAfter(range.getTo())) {
        break;
      }

      if (currentRange.isAfter(from)) {
        // log.info("a from " + from + " to " + currentRange.getFrom());
        list.add(new IntRange(from, currentRange.getFrom()));
      }

      from = currentRange.getTo();

      if (from >= to)
        break;
    }

    if (from < to) {
      // log.info("b from " + from + " to " + to);
      list.add(new IntRange(from, to));
    }

    return list.toArray(new IntRange[list.size()]);
  }
View Full Code Here

      int newFrom = currentRange.getTo();
      int newTo = Math.min(length, newFrom + BUFFER);

      if (newFrom < newTo) {
        currentRange = new IntRange(newFrom, newTo);

        currentIterator = index.get(currentRange).listIterator();

        hasNext = currentIterator.hasNext();
      } else {
View Full Code Here

  private List<Line> EMPTY_LIST = Collections.emptyList();

  public void moveTo(int position) {
    currentIterator = EMPTY_LIST.listIterator();
    currentRange = new IntRange(position, position);
  }
View Full Code Here

    int minimumOffset = minimumOffset();
    while (!hasPrevious && currentRange.getFrom() > minimumOffset) {
      int newFrom = Math.max(minimumOffset, currentRange.getFrom() - BUFFER);
      int newTo = currentRange.getFrom();

      currentRange = new IntRange(newFrom, newTo);

      log.debug("new range " + currentRange);

      List<Line> list = index.get(currentRange);
      currentIterator = list.listIterator(list.size());
View Full Code Here

    this.values = values;
  }

  // TODO addAll rather than merge, reduce number of increments
  public MemoryIntField merge(MemoryIntField other) {
    IntRange newRange = range.merge(other.range);

    IntList newList;

    if (range.getFrom() < other.range.getFrom()) {
      values.addAll(other.values);
View Full Code Here

  }

  public List<Line> get(IntRange region) {
    int to = region.getTo();

    IntRange newRange = new IntRange(region);
    newRange.setTo(Math.min(to + GloogyConstants.LINE_CUTOFF, text.length()));

    IntList list = index.get(newRange);

    if (list == null) {
      throw new NullPointerException("unable to index range " + newRange + " length of input " + text.length());
    }

    List<Line> l = new ArrayList<Line>(list.size());

    int[] values = list.toArray(new int[list.size()]);
    int lineStart = 0;
    int lineEnd = 0;

    for (int i = 0; i < values.length; i++) {
      lineStart = values[i];

      if (lineStart >= to)
        break;

      // TODO should we extend the search area?
      lineEnd = (i == values.length - 1) ? newRange.getTo() : values[i + 1];

      // TODO check if this is safe, strip newlines
      lineEnd--;

      Line line = buildLine(lineStart, lineEnd);
View Full Code Here

TOP

Related Classes of com.baulsupp.kolja.log.util.IntRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.