Java 类java.util.ListIterator 实例源码

项目:Lagerta    文件:MergeUtil.java   
/**
 * merges two collections
 *
 * @param first      result list
 * @param second     merges with first list
 * @param comparator
 */
public static <T> void merge(List<T> first, List<T> second, Comparator<T> comparator) {
    ListIterator<T> firstIter = first.listIterator();
    ListIterator<T> secondIter = second.listIterator();

    T a = getNext(firstIter);
    T b = getNext(secondIter);

    while (a != null && b != null) {
        if (comparator.compare(a, b) > 0) {
            firstIter.previous();
            firstIter.add(b);
            firstIter.next();
            b = getNext(secondIter);
        } else {
            a = getNext(firstIter);
        }
    }

    while (b != null) {
        firstIter.add(b);
        b = getNext(secondIter);
    }
}
项目:node-boilerpipe    文件:TrailingHeadlineToBoilerplateFilter.java   
public boolean process(TextDocument doc) throws BoilerpipeProcessingException {
  boolean changes = false;

  List<TextBlock> list = doc.getTextBlocks();

  for (ListIterator<TextBlock> it = list.listIterator(list.size()); it.hasPrevious();) {
    TextBlock tb = it.previous();
    if (tb.isContent()) {
      if (tb.hasLabel(DefaultLabels.HEADING)) {
        tb.setIsContent(false);
        changes = true;
      } else {
        break;
      }
    }
  }

  return changes;
}
项目:GitHub    文件:RangeLayoutHelperFinder.java   
@Override
protected Iterable<LayoutHelper> reverse() {
    final ListIterator<LayoutHelper> i = mLayoutHelpers.listIterator(mLayoutHelpers.size());
    return new Iterable<LayoutHelper>() {
        @Override
        public Iterator<LayoutHelper> iterator() {
            return new Iterator<LayoutHelper>() {
                public boolean hasNext() {
                    return i.hasPrevious();
                }

                public LayoutHelper next() {
                    return i.previous();
                }

                public void remove() {
                    i.remove();
                }
            };
        }
    };
}
项目:s-store    文件:Lists.java   
/**
 * An implementation of {@link List#subList(int, int)}.
 */
static <E> List<E> subListImpl(
    final List<E> list, int fromIndex, int toIndex) {
  List<E> wrapper;
  if (list instanceof RandomAccess) {
    wrapper = new RandomAccessListWrapper<E>(list) {
      @Override public ListIterator<E> listIterator(int index) {
        return backingList.listIterator(index);
      }

      private static final long serialVersionUID = 0;
    };
  } else {
    wrapper = new AbstractListWrapper<E>(list) {
      @Override public ListIterator<E> listIterator(int index) {
        return backingList.listIterator(index);
      }

      private static final long serialVersionUID = 0;
    };
  }
  return wrapper.subList(fromIndex, toIndex);
}
项目:ZooKeeper    文件:ClientCnxnSocketNIO.java   
private Packet findSendablePacket(LinkedList<Packet> outgoingQueue,
                                  boolean clientTunneledAuthenticationInProgress) {
    synchronized (outgoingQueue) {
        if (outgoingQueue.isEmpty()) {
            return null;
        }
        if (outgoingQueue.getFirst().bb != null // If we've already starting sending the first packet, we better finish
            || !clientTunneledAuthenticationInProgress) {
            return outgoingQueue.getFirst();
        }

        // Since client's authentication with server is in progress,
        // send only the null-header packet queued by primeConnection().
        // This packet must be sent so that the SASL authentication process
        // can proceed, but all other packets should wait until
        // SASL authentication completes.
        ListIterator<Packet> iter = outgoingQueue.listIterator();
        while (iter.hasNext()) {
            Packet p = iter.next();
            if (p.requestHeader == null) {
                // We've found the priming-packet. Move it to the beginning of the queue.
                iter.remove();
                outgoingQueue.add(0, p);
                return p;
            } else {
                // Non-priming packet: defer it until later, leaving it in the queue
                // until authentication completes.
                if (LOG.isDebugEnabled()) {
                    LOG.debug("deferring non-priming packet: " + p +
                            "until SASL authentication completes.");
                }
            }
        }
        // no sendable packet found.
        return null;
    }
}
项目:athena    文件:KeyListenerTest.java   
/**
 * Checks key values are set correctly.
 */
@Test
public void processKeyWithUsesInList() throws IOException, ParserException {
    YangNode node = manager.getDataModel("src/test/resources/KeyWithUsesInList.yang");

    assertThat((node instanceof YangModule), is(true));
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    // Check whether the list is child of module
    YangList yangList = (YangList) yangNode.getChild().getNextSibling();
    assertThat(yangList.getName(), is("valid"));

    ListIterator<String> keyList = yangList.getKeyList().listIterator();
    assertThat(keyList.next(), is("invalid-interval"));
}
项目:RNLearn_Project1    文件:NativeAnimatedNodesManager.java   
public void removeAnimatedEventFromView(int viewTag, String eventName, int animatedValueTag) {
  String key = viewTag + eventName;
  if (mEventDrivers.containsKey(key)) {
    List<EventAnimationDriver> driversForKey = mEventDrivers.get(key);
    if (driversForKey.size() == 1) {
      mEventDrivers.remove(viewTag + eventName);
    } else {
      ListIterator<EventAnimationDriver> it = driversForKey.listIterator();
      while (it.hasNext()) {
        if (it.next().mValueNode.mTag == animatedValueTag) {
          it.remove();
          break;
        }
      }
    }
  }
}
项目:mupdf-android-viewer-nui    文件:DocPageView.java   
private PageAnnotation getSelectedAnnotation()
{
    if (mAnnotations != null)
    {
        //  iterate in reverse order
        ListIterator<PageAnnotation> li = mAnnotations.listIterator(mAnnotations.size());
        while (li.hasPrevious())
        {
            PageAnnotation annot = li.previous();
            if (annot.isSelected())
            {
                return annot;
            }
        }
    }

    return null;
}
项目:HCFCore    文件:ListIteratorWrapper.java   
/**
 * Returns the next element from the iterator.
 *
 * @return the next element from the iterator
 * @throws NoSuchElementException if there are no more elements
 */
public E next() throws NoSuchElementException {
    if (iterator instanceof ListIterator) {
        return iterator.next();
    }

    if (currentIndex < wrappedIteratorIndex) {
        ++currentIndex;
        return list.get(currentIndex - 1);
    }

    final E retval = iterator.next();
    list.add(retval);
    ++currentIndex;
    ++wrappedIteratorIndex;
    removeState = true;
    return retval;
}
项目:athena    文件:KeyListenerTest.java   
/**
 * Checks key statement as sub-statement of list.
 */
@Test
public void processListSubStatementKey() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/ListSubStatementKey.yang");

    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    // Check whether the list is child of module
    YangList yangList = (YangList) yangNode.getChild();
    assertThat(yangList.getName(), is("valid"));

    ListIterator<String> keyList = yangList.getKeyList().listIterator();
    assertThat(keyList.next(), is("invalid-interval"));
}
项目:DicomViewer    文件:SortedListTools.java   
private static <T> int iteratorBinarySearch(final List<? extends Comparable<? super T>> list, final T key, int low, int high)  {
    final ListIterator<? extends Comparable<? super T>> i = list.listIterator();
    int mid, cmp;
    while (low <= high) {
        mid = (low + high) >>> 1;
        cmp = get(i, mid).compareTo(key);

        if (cmp < 0) {
            low = mid + 1;
        } else if (cmp > 0) {
            high = mid - 1;
        } else {
            return mid;
        } // key found
    }
    return -(low + 1);  // key not found
}
项目:athena    文件:PatternRestrictionListenerTest.java   
/**
 * Checks valid pattern statement with plus symbol in pattern.
 */
@Test
public void processPatternStatementWithPlus() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/PatternStatementWithPlus.yang");

    assertThat((node instanceof YangModule), is(true));
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
    YangLeafList leafListInfo = leafListIterator.next();

    assertThat(leafListInfo.getName(), is("invalid-interval"));
    assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
    assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
    YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
            .getDataType().getDataTypeExtendedInfo();
    ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
            .getPatternList().listIterator();
    assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+"));
}
项目:hanlpStudy    文件:NotionalTokenizer.java   
/**
 * 切分为句子形式
 *
 * @param text
 * @return
 */
public static List<List<Term>> seg2sentence(String text)
{
    List<List<Term>> sentenceList = SEGMENT.seg2sentence(text);
    for (List<Term> sentence : sentenceList)
    {
        ListIterator<Term> listIterator = sentence.listIterator();
        while (listIterator.hasNext())
        {
            if (!CoreStopWordDictionary.shouldInclude(listIterator.next()))
            {
                listIterator.remove();
            }
        }
    }

    return sentenceList;
}
项目:athena    文件:PatternRestrictionListenerTest.java   
/**
 * Checks valid pattern statement as sub-statement of leaf statement.
 */
@Test
public void processValidPatternStatement() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/ValidPatternStatement.yang");

    assertThat((node instanceof YangModule), is(true));
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
    assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
    YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
            .getDataType().getDataTypeExtendedInfo();
    ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
            .getPatternList().listIterator();
    assertThat(patternListIterator.next(), is("[a-zA-Z]"));
}
项目:athena    文件:DescriptionListenerTest.java   
/**
 * Checks valid description statement.
 */
@Test
public void processDescriptionValidStatement() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/DescriptionValidStatement.yang");

    // Check whether the data model tree returned is of type module.
    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    // Check whether the description is set correctly.
    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
}
项目:athena    文件:ContainerListenerTest.java   
/**
 * Checks container statement as sub-statement of list.
 */
@Test
public void processListSubStatementContainer() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/ListSubStatementContainer.yang");

    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    // Check whether the list is child of module
    YangList yangList1 = (YangList) yangNode.getChild();
    assertThat(yangList1.getName(), is("ospf"));

    ListIterator<String> keyList = yangList1.getKeyList().listIterator();
    assertThat(keyList.next(), is("process-id"));

    // Check whether the list is child of list
    YangContainer yangContainer = (YangContainer) yangList1.getChild();
    assertThat(yangContainer.getName(), is("interface"));
}
项目:Equella    文件:InstitutionImportServiceImpl.java   
protected void doErrorCleanup(final TemporaryFileHandle staging, final List<String> tasksDone,
    final Institution institution, final ConverterParams params)
{
    runAs.executeAsSystem(institution, new Runnable()
    {
        @Override
        public void run()
        {
            tasksDone.add(0, ConverterId.CLEANUPFILES.name());
            ListIterator<String> iter = tasksDone.listIterator(tasksDone.size());

            while( iter.hasPrevious() )
            {
                String task = iter.previous();
                getConverter(task).deleteIt(staging, institution, params, task);
            }
            instService.deleteInstitution(institution);
        }
    });
}
项目:xsharing-services-router    文件:AbstractModeStrategy.java   
<TUPLE extends StationTuple> ListIterator<TUPLE> getListIterator(List<TUPLE> fromTuples) {
    if (useLiveStatus) {
        return fromTuples.listIterator();
    } else {
        List<TUPLE> out;
        if (fromTuples.isEmpty()) {
            out = Collections.emptyList();
        } else {
            out = fromTuples.subList(0, 1);
        }
        return out.listIterator();
    }
}
项目:hadoop-oss    文件:Configuration.java   
private <T> void toString(List<T> resources, StringBuilder sb) {
  ListIterator<T> i = resources.listIterator();
  while (i.hasNext()) {
    if (i.nextIndex() != 0) {
      sb.append(", ");
    }
    sb.append(i.next());
  }
}
项目:Reer    文件:AstUtils.java   
public static void filterAndTransformStatements(SourceUnit source, StatementTransformer transformer) {
    ListIterator<Statement> statementIterator = source.getAST().getStatementBlock().getStatements().listIterator();
    while (statementIterator.hasNext()) {
        Statement originalStatement = statementIterator.next();
        Statement transformedStatement = transformer.transform(source, originalStatement);
        if (transformedStatement == null) {
            statementIterator.remove();
        } else if (transformedStatement != originalStatement) {
            statementIterator.set(transformedStatement);
        }
    }
}
项目:athena    文件:BgpFlowSpecNlri.java   
/**
 * Update buffer with non-identical flow types.
 *
 * @param cb channel buffer
 */
public static void updateBufferNonIdenticalFlowTypes(ChannelBuffer cb, BgpFlowSpecNlri bgpFlowSpecNlri) {
    ChannelBuffer flowSpecTmpBuff = ChannelBuffers.dynamicBuffer();
    List<BgpValueType> flowSpec = bgpFlowSpecNlri.flowSpecComponents();
    ListIterator<BgpValueType> listIterator = flowSpec.listIterator();
    int tmpBuffStartIndx = flowSpecTmpBuff.writerIndex();

    flowSpec = bgpFlowSpecNlri.flowSpecComponents();
    listIterator = flowSpec.listIterator();

    while (listIterator.hasNext()) {
        BgpValueType tlv = listIterator.next();
        writeFlowType(tlv, flowSpecTmpBuff);
    }

    /* RFC 5575: section 4,  If the NLRI length value is smaller than 240 (0xf0 hex), the length
                             field can be encoded as a single octet.  Otherwise, it is encoded as
                             an extended-length 2-octet values */
    int len = flowSpecTmpBuff.writerIndex() - tmpBuffStartIndx;
    if (len >= FLOW_SPEC_LEN) {
        cb.writeShort(len);
    } else {
        cb.writeByte(len);
    }
    //Copy from bynamic buffer to channel buffer
    cb.writeBytes(flowSpecTmpBuff);
}
项目:Reer    文件:StatementReplacingVisitorSupport.java   
/**
 * Visits the statements in the specified mutable list. If a statement's
 * visit method calls replaceVisitedMethodWith(), the statement will be
 * replaced.
 */
@SuppressWarnings("unchecked")
protected <T extends Statement> void replaceAll(List<T> stats) {
  ListIterator<T> iter = stats.listIterator();
    while (iter.hasNext()) {
        iter.set((T) replace(iter.next()));
    }
}
项目:Reer    文件:FilteredList.java   
public ListIterator<S> listIterator(int index) {
    ListIterator<S> iterator = listIterator();
    for (int i = 0; i < index; i++) {
        iterator.next();
    }
    return iterator;
}
项目:node-boilerpipe    文件:IgnoreBlocksAfterContentFromEndFilter.java   
public boolean process(TextDocument doc) throws BoilerpipeProcessingException {
  boolean changes = false;

  int words = 0;

  List<TextBlock> blocks = doc.getTextBlocks();
  if (!blocks.isEmpty()) {
    ListIterator<TextBlock> it = blocks.listIterator(blocks.size());

    TextBlock tb;

    while (it.hasPrevious()) {
      tb = it.previous();
      if (tb.hasLabel(DefaultLabels.INDICATES_END_OF_TEXT)) {
        tb.addLabel(DefaultLabels.STRICTLY_NOT_CONTENT);
        tb.removeLabel(DefaultLabels.MIGHT_BE_CONTENT);
        tb.setIsContent(false);
        changes = true;
      } else if (tb.isContent()) {
        words += tb.getNumWords();
        if (words > 200) {
          break;
        }
      }

    }
  }

  return changes;
}
项目:hanlpStudy    文件:WordBasedGenerativeModelSegment.java   
private static void SplitMiddleSlashFromDigitalWords(
        List<Vertex> linkedArray) {
    if (linkedArray.size() < 2)
        return;

    ListIterator<Vertex> listIterator = linkedArray.listIterator();
    Vertex next = listIterator.next();
    Vertex current = next;
    while (listIterator.hasNext()) {
        next = listIterator.next();
        // System.out.println("current:" + current + " next:" + next);
        Nature currentNature = current.getNature();
        if (currentNature == Nature.nx
                && (next.hasNature(Nature.q) || next.hasNature(Nature.n))) {
            String[] param = current.realWord.split("-", 1);
            if (param.length == 2) {
                if (TextUtility.isAllNum(param[0])
                        && TextUtility.isAllNum(param[1])) {
                    current = current.copy();
                    current.realWord = param[0];
                    current.confirmNature(Nature.m);
                    listIterator.previous();
                    listIterator.previous();
                    listIterator.set(current);
                    listIterator.next();
                    listIterator.add(Vertex.newPunctuationInstance("-"));
                    listIterator.add(Vertex.newNumberInstance(param[1]));
                }
            }
        }
        current = next;
    }

    // logger.trace("杠号识别后:" + Graph.parseResult(linkedArray));
}
项目:ContentAssist    文件:diff_match_patch.java   
/**
 * Do a quick line-level diff on both strings, then rediff the parts for
 * greater accuracy.
 * This speedup can produce non-minimal diffs.
 * @param text1 Old string to be diffed.
 * @param text2 New string to be diffed.
 * @param deadline Time when the diff should be complete by.
 * @return Linked List of Diff objects.
 */
private LinkedList<Diff> diff_lineMode(String text1, String text2,
                                       long deadline) {
  // Scan the text on a line-by-line basis first.
  LinesToCharsResult b = diff_linesToChars(text1, text2);
  text1 = b.chars1;
  text2 = b.chars2;
  List<String> linearray = b.lineArray;

  LinkedList<Diff> diffs = diff_main(text1, text2, false, deadline);

  // Convert the diff back to original text.
  diff_charsToLines(diffs, linearray);
  // Eliminate freak matches (e.g. blank lines)
  diff_cleanupSemantic(diffs);

  // Rediff any replacement blocks, this time character-by-character.
  // Add a dummy entry at the end.
  diffs.add(new Diff(Operation.EQUAL, ""));
  int count_delete = 0;
  int count_insert = 0;
  String text_delete = "";
  String text_insert = "";
  ListIterator<Diff> pointer = diffs.listIterator();
  Diff thisDiff = pointer.next();
  while (thisDiff != null) {
    switch (thisDiff.operation) {
    case INSERT:
      count_insert++;
      text_insert += thisDiff.text;
      break;
    case DELETE:
      count_delete++;
      text_delete += thisDiff.text;
      break;
    case EQUAL:
      // Upon reaching an equality, check for prior redundancies.
      if (count_delete >= 1 && count_insert >= 1) {
        // Delete the offending records and add the merged ones.
        pointer.previous();
        for (int j = 0; j < count_delete + count_insert; j++) {
          pointer.previous();
          pointer.remove();
        }
        for (Diff newDiff : diff_main(text_delete, text_insert, false,
            deadline)) {
          pointer.add(newDiff);
        }
      }
      count_insert = 0;
      count_delete = 0;
      text_delete = "";
      text_insert = "";
      break;
    }
    thisDiff = pointer.hasNext() ? pointer.next() : null;
  }
  diffs.removeLast();  // Remove the dummy entry at the end.

  return diffs;
}
项目:LightSIP    文件:SIPMessage.java   
/**
 * Set a header from a linked list of headers.
 *
 * @param headers -- a list of headers to set.
 */
public void setHeaders(java.util.List<SIPHeader> headers) {
    ListIterator<SIPHeader> listIterator = headers.listIterator();
    while (listIterator.hasNext()) {
        SIPHeader sipHeader = (SIPHeader) listIterator.next();
        try {
            this.attachHeader(sipHeader, false);
        } catch (SIPDuplicateHeaderException ex) {
        }
    }
}
项目:athena    文件:BgpFlowSpecNlri.java   
/**
 * Update buffer with identical flow types.
 *
 * @param cb channel buffer
 */
public static void updateBufferIdenticalFlowTypes(ChannelBuffer cb, BgpFlowSpecNlri bgpFlowSpecNlri) {

    List<BgpValueType> flowSpec = bgpFlowSpecNlri.flowSpecComponents();
    ListIterator<BgpValueType> listIterator = flowSpec.listIterator();

    while (listIterator.hasNext()) {
        ChannelBuffer flowSpecTmpBuff = ChannelBuffers.dynamicBuffer();
        int tmpBuffStartIndx = flowSpecTmpBuff.writerIndex();

        BgpValueType tlv = listIterator.next();
        writeFlowType(tlv, flowSpecTmpBuff);

        /* RFC 5575: section 4,  If the NLRI length value is smaller than 240 (0xf0 hex), the length
                                 field can be encoded as a single octet.  Otherwise, it is encoded as
                                 an extended-length 2-octet values */
        int len = flowSpecTmpBuff.writerIndex() - tmpBuffStartIndx;
        if (len >= FLOW_SPEC_LEN) {
            cb.writeShort(len);
        } else {
            cb.writeByte(len);
        }
        //Copy from bynamic buffer to channel buffer
        cb.writeBytes(flowSpecTmpBuff);
    }
    return;
}
项目:GitHub    文件:BaseRecyclerAdapter.java   
/** 移除一条数据 */
public void removeItem(T item) {
    int position = 0;
    ListIterator<T> iterator = mDatas.listIterator();
    while (iterator.hasNext()) {
        T next = iterator.next();
        if (next == item) {
            iterator.remove();
            notifyItemRemoved(position);
        }
        position++;
    }
}
项目:LivroJavaComoProgramar10Edicao    文件:ListTest.java   
private static void printReversedList(List<String> list)
{
   ListIterator<String> iterator = list.listIterator(list.size());

   System.out.printf("%nReversed List:%n");

   // print list in reverse order
   while (iterator.hasPrevious()) 
      System.out.printf("%s ", iterator.previous()); 
}
项目:KSP-AGuS-Automatic-Guidance-System    文件:TRANSFER_HOHMANN.java   
/**
 * Will delete Maneuvers that had errors while creating
 */
private void deleteEmptyManeuver() {
    List<Integer> li = new ArrayList<Integer>();
    ListIterator<MANEUVER> mi = getManeuverList().listIterator();
    while (mi.hasNext()) {
        if (mi.next().errors()) {
            mi.remove();
        }
    }

}
项目:OpenJSharp    文件:DefaultKeyboardFocusManager.java   
/**
 * Delays dispatching of KeyEvents until the specified Component becomes
 * the focus owner. KeyEvents with timestamps later than the specified
 * timestamp will be enqueued until the specified Component receives a
 * FOCUS_GAINED event, or the AWT cancels the delay request by invoking
 * <code>dequeueKeyEvents</code> or <code>discardKeyEvents</code>.
 *
 * @param after timestamp of current event, or the current, system time if
 *        the current event has no timestamp, or the AWT cannot determine
 *        which event is currently being handled
 * @param untilFocused Component which will receive a FOCUS_GAINED event
 *        before any pending KeyEvents
 * @see #dequeueKeyEvents
 * @see #discardKeyEvents
 */
protected synchronized void enqueueKeyEvents(long after,
                                             Component untilFocused) {
    if (untilFocused == null) {
        return;
    }

    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("Enqueue at {0} for {1}",
                   after, untilFocused);
    }

    int insertionIndex = 0,
        i = typeAheadMarkers.size();
    ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator(i);

    for (; i > 0; i--) {
        TypeAheadMarker marker = iter.previous();
        if (marker.after <= after) {
            insertionIndex = i;
            break;
        }
    }

    typeAheadMarkers.add(insertionIndex,
                         new TypeAheadMarker(after, untilFocused));
}
项目:GitHub    文件:RealmList.java   
/**
 * {@inheritDoc}
 */
@Override
@Nonnull
public ListIterator<E> listIterator(int location) {
    if (isManaged()) {
        return new RealmListItr(location);
    } else {
        return super.listIterator(location);
    }
}
项目:xdman    文件:UnixFTPEntryParser.java   
/**
 * Preparse the list to discard "total nnn" lines
 */
@Override
public List<String> preParse(List<String> original) {
    ListIterator<String> iter = original.listIterator();
    while (iter.hasNext()) {
        String entry = iter.next();
        if (entry.matches("^total \\d+$")) { // NET-389
            iter.remove();
        }
    }
    return original;
}
项目:FactionsXL    文件:FDefaultSidebar.java   
public List<String> getOutput(FPlayer fplayer, List<String> content) {
    content = new ArrayList<>(content);
    ListIterator<String> it = content.listIterator();
    while (it.hasNext()) {
        it.set(replaceTags(fplayer, it.next()));
    }

    return content;
}
项目:googles-monorepo-demo    文件:Lists.java   
/**
 * An implementation of {@link List#lastIndexOf(Object)}.
 */
static int lastIndexOfImpl(List<?> list, @Nullable Object element) {
  if (list instanceof RandomAccess) {
    return lastIndexOfRandomAccess(list, element);
  } else {
    ListIterator<?> listIterator = list.listIterator(list.size());
    while (listIterator.hasPrevious()) {
      if (Objects.equal(element, listIterator.previous())) {
        return listIterator.nextIndex();
      }
    }
    return -1;
  }
}
项目:xsharing-services-router    文件:RouteLegFactory.java   
private static StationRepresentation extractStation(ListIterator<StationRepresentation> iterator) throws Exception {
    if (iterator.hasNext()) {
        return iterator.next();

    } else {
        throw new Exception();
    }
}
项目:openjdk-jdk10    文件:GraalCompilerTest.java   
protected PhaseSuite<HighTierContext> getCustomGraphBuilderSuite(GraphBuilderConfiguration gbConf) {
    PhaseSuite<HighTierContext> suite = getDefaultGraphBuilderSuite();
    ListIterator<BasePhase<? super HighTierContext>> iterator = suite.findPhase(GraphBuilderPhase.class);
    initializeInvocationPluginExtensions();
    GraphBuilderConfiguration gbConfCopy = editGraphBuilderConfiguration(gbConf.copy());
    iterator.remove();
    iterator.add(new GraphBuilderPhase(gbConfCopy));
    return suite;
}
项目:googles-monorepo-demo    文件:Lists.java   
@Override
public ListIterator<T> listIterator(int index) {
  return new TransformedListIterator<F, T>(fromList.listIterator(index)) {
    @Override
    T transform(F from) {
      return function.apply(from);
    }
  };
}
项目:VASSAL-src    文件:Node.java   
public String getPath() {
  synchronized (children) {
    SequenceEncoder se = new SequenceEncoder('/');
    List<Node> path = getPathList();
    for (ListIterator<Node> i = path.listIterator(path.size());
         i.hasPrevious(); ) {
      se.append(i.previous().getId());
    }
    return se.getValue();
  }
}