Package org.apache.commons.collections.primitives

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


    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);
    }

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

  public int length() {
    return li.length();
  }

  protected void processLines(IntRange region, List<Line> regionLines) {
    IntList values = new ArrayIntList();

    for (Line line : regionLines) {
      processLine(values, line);
    }
View Full Code Here

  }

  public List<Line> get(IntRange region) {
    ensureKnown(region);

    IntList offsets = indexed.get(region);

    if (offsets == null) {
      throw new NullPointerException(region.toString() + " " + li.length() + " " + Arrays.asList(indexed.listUnknownRanges(region)));
    }
View Full Code Here

  public int length() {
    return li.length();
  }

  protected void processLines(IntRange region, List<Line> regionLines) {
    IntList values = new ArrayIntList();

    for (Line line : regionLines) {
      Object requestId = line.getValue(requestField);

      RequestLine requestLine = requestsById.get(requestId);
View Full Code Here

  }

  public List<Line> get(IntRange region) {
    ensureKnown(region);

    IntList offsets = indexed.get(region);

    if (offsets == null) {
      throw new NullPointerException(region.toString() + " " + li.length() + " "
          + Arrays.asList(indexed.listUnknownRanges(region)));
    }
View Full Code Here

  public static void main(String[] args) {
    StopWatch w = new StopWatch(1);
    w.begin(true);
    // This is slower!
    for (int i = 0; i < 1000; ++i) {
        IntList inList = new ArrayIntList(10000);
      Stop s = w.start();
      for (int j = 0; j < 10000; ++j) {
        inList.add(j);
      }
      s.stop();
    }
    w.done();
    w.print();
View Full Code Here

      return DocIdSet.EMPTY_DOCIDSET;
    } else if (docIdSet.isCacheable()) {
      return docIdSet;
    } else {
      DocIdSetIterator it = docIdSet.iterator();
      IntList docIds = new ArrayIntList();

      // null is allowed to be returned by iterator(),
      // in this case we wrap with the empty set,
      // which is cacheable.
      if (it == null) {
        return DocIdSet.EMPTY_DOCIDSET;
      } else {
        while (it.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
          docIds.add(it.docID());
        }
        return new IntListDocIdSet(docIds);
      }
    }
  }
View Full Code Here

    int effectiveFrom = from - lookBack;

    matcher.reset(text.subSequence(effectiveFrom, newTo));

    // TODO pool int lists
    IntList result = new FastIntList(100);

    boolean found = matcher.find(lookBack);

    while (found) {
      int pos = matcher.start() + effectiveFrom;

      if (pos >= to) {
        break;
      }

      result.add(pos);

      found = matcher.find();
    }

    return result;
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.