code: private void fillQueue(QueueItem item, Integer minStartPosition,
        Integer maxStartPosition, Integer minEndPosition) throws IOException {
      int newStartPosition;
      int newEndPosition;
      Integer firstRetrievedPosition = null;
      // remove everything below minStartPosition
      if ((minStartPosition != null) && (item.lowestPosition != null)
          && (item.lowestPosition < minStartPosition)) {
        item.del((minStartPosition - 1));
      }
      // fill queue
      while (!item.noMorePositions) {
        boolean doNotCollectAnotherPosition;
        doNotCollectAnotherPosition = item.filledPosition
            && (minStartPosition == null) && (maxStartPosition == null);
        doNotCollectAnotherPosition |= item.filledPosition
            && (maxStartPosition != null) && (item.lastRetrievedPosition != null)
            && (maxStartPosition < item.lastRetrievedPosition);
        if (doNotCollectAnotherPosition) {
          return;
        } else {
          // collect another full position
          firstRetrievedPosition = null;
          while (!item.noMorePositions) {
            newStartPosition = item.sequenceSpans.spans.nextStartPosition();
            if (newStartPosition == NO_MORE_POSITIONS) {
              if (!item.queue.isEmpty()) {
                item.filledPosition = true;
                item.lastFilledPosition = item.lastRetrievedPosition;
              }
              item.noMorePositions = true;
              return;
            } else if ((minStartPosition != null)
                && (newStartPosition < minStartPosition)) {
              // do nothing
            } else {
              newEndPosition = item.sequenceSpans.spans.endPosition();
              if ((minEndPosition == null) || (newEndPosition >= minEndPosition
                  - ignoreItem.getMinStartPosition(docId, newEndPosition))) {
                item.add(newStartPosition, newEndPosition);
                if (firstRetrievedPosition == null) {
                  firstRetrievedPosition = newStartPosition;
                } else if (!firstRetrievedPosition.equals(newStartPosition)) {
                  break;
                }
              }
            }
          }
        }
      }
    }
docs: Fill queue.
  
  @param item the item
  @param minStartPosition the min start position
  @param maxStartPosition the max start position
  @param minEndPosition the min end position
  @throws IOException Signals that an I/O exception has occurred.