Package org.apache.commons.collections.primitives

Examples of org.apache.commons.collections.primitives.IntList


  public BufferedLogEntryIndex(LogEntryIndex index) {
    this.index = index;
  }

  public IntList get(IntRange region) {
    IntList result = field.get(region);

    log.debug("buf " + region);

    if (result == null) {
      IntRange[] missing = field.listUnknownRanges(region);
      for (int i = 0; i < missing.length; i++) {
        // TODO problem here!
        log.debug("missing " + missing[i]);
        IntList l = index.get(missing[i]);

        field.add(new MemoryIntField(missing[i], l));
      }

      result = field.get(region);
View Full Code Here


  // 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);
      newList = values;
    } else {
View Full Code Here

    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];
View Full Code Here

    this.lineIndex = lineIndex;
    this.buffer = buffer;
  }

  public int lineNumber(int position) {
    IntList l = readUpTo(position + 1);

    return l.size();
  }
View Full Code Here

    return l.size();
  }

  private IntList readUpTo(int position) {
    position = Math.min(position, buffer.length());
    IntList result = lineIndex.get(new IntRange(0, position));

    positionRead = Math.max(positionRead, position);
    linesRead = result.size();

    return result;
  }
View Full Code Here

  public int offset(int lineNumber) {
    if (lineNumber == 0) {
      return 0;
    }

    IntList l = null;
    while (l == null || linesRead <= lineNumber) {
      int estimate = estimateNeeded(lineNumber);
      l = readUpTo(estimate);

      if (linesRead <= lineNumber && positionRead >= buffer.length()) {
        return -1;
      }
    }

    return l.get(lineNumber);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.primitives.IntList

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.