java.util.ListIterator#next ( )源码实例Demo

下面列出了java.util.ListIterator#next ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk8u-backup   文件: AuthCacheImpl.java
public synchronized void remove (String pkey, AuthCacheValue entry) {
    LinkedList<AuthCacheValue> list = hashtable.get (pkey);
    if (list == null) {
        return;
    }
    if (entry == null) {
        list.clear();
        return;
    }
    ListIterator<AuthCacheValue> iter = list.listIterator ();
    while (iter.hasNext()) {
        AuthenticationInfo inf = (AuthenticationInfo)iter.next();
        if (entry.equals(inf)) {
            iter.remove ();
        }
    }
}
 
/**
 * Returns the unioned {@link #getVisualBounds(IContentPart) bounds} of all
 * target parts.
 *
 * @param targetParts
 * @return the unioned visual bounds of all target parts
 */
private Rectangle getSelectionBounds(
		List<IContentPart<? extends Node>> targetParts) {
	if (targetParts.isEmpty()) {
		throw new IllegalArgumentException("No target parts given.");
	}

	Rectangle bounds = getVisualBounds(targetParts.get(0));
	if (targetParts.size() == 1) {
		return bounds;
	}

	ListIterator<IContentPart<? extends Node>> iterator = targetParts
			.listIterator(1);
	while (iterator.hasNext()) {
		IContentPart<? extends Node> cp = iterator.next();
		if (bounds == null) {
			bounds = getVisualBounds(cp);
		} else {
			bounds.union(getVisualBounds(cp));
		}
	}
	return bounds;
}
 
源代码3 项目: itext2   文件: PdfContentStreamProcessor.java
public static byte[] getContentBytesFromPdfObject(PdfObject object) throws IOException {
	switch (object.type()) {
	case PdfObject.INDIRECT:
		return getContentBytesFromPdfObject(PdfReader.getPdfObject(object));
	case PdfObject.STREAM:
		return PdfReader.getStreamBytes((PRStream) PdfReader.getPdfObject(object));
	case PdfObject.ARRAY:
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ListIterator<PdfObject> iter = ((PdfArray) object).listIterator();
		while (iter.hasNext()) {
			PdfObject element = iter.next();
			baos.write(getContentBytesFromPdfObject(element));
		}
		return baos.toByteArray();
	default:
		throw new IllegalStateException("Unsupported type: " + object.getClass().getCanonicalName());
	}
}
 
源代码4 项目: ion-java   文件: IonDatagramLite.java
public IonValue systemGet(int index) throws IndexOutOfBoundsException
{
    ListIterator<IonValue> iterator = systemIterator();
    IonValue value = null;

    if (index < 0) {
        throw new IndexOutOfBoundsException(""+index);
    }

    int ii;
    for (ii=0; ii<=index; ii++) {
        if (!iterator.hasNext()) {
            throw new IndexOutOfBoundsException(""+index);
        }
        value = iterator.next();
    }
    return value;
}
 
/**
 * Inserts timestamps in order into a linked list.
 * If timestamps arrive in order (as in case of using the RocksDB state backend) this is just
 * an append with O(1).
 */
private void insertToSortedList(Long recordTimestamp) {
	ListIterator<Long> listIterator = sortedTimestamps.listIterator(sortedTimestamps.size());
	boolean isContinue = true;
	while (listIterator.hasPrevious() && isContinue) {
		Long timestamp = listIterator.previous();
		if (recordTimestamp >= timestamp) {
			listIterator.next();
			listIterator.add(recordTimestamp);
			isContinue = false;
		}
	}

	if (isContinue) {
		sortedTimestamps.addFirst(recordTimestamp);
	}
}
 
源代码6 项目: iBeebo   文件: HotWeiboStatusListAdapter.java
public void addNewData(List<MessageBean> newValue) {

        if (newValue == null || newValue.size() == 0) {
            return;
        }

        this.bean.addAll(0, newValue);

        // remove duplicate null flag, [x,y,null,null,z....]

        ListIterator<MessageBean> listIterator = this.bean.listIterator();

        boolean isLastItemNull = false;
        while (listIterator.hasNext()) {
            MessageBean msg = listIterator.next();
            if (msg == null) {
                if (isLastItemNull) {
                    listIterator.remove();
                }
                isLastItemNull = true;
            } else {
                isLastItemNull = false;
            }
        }
    }
 
源代码7 项目: WMRouter   文件: PriorityList.java
/**
 * 添加Item并指定优先级
 */
public boolean addItem(T item, int priority) {
    Node<T> node = new Node<>(item, priority);
    if (mList.isEmpty()) {
        mList.add(node);
        return true;
    }
    // 插入排序,list中的priority从大到小排列
    ListIterator<Node<T>> iterator = mList.listIterator();
    while (iterator.hasNext()) {
        Node<T> next = iterator.next();
        if (next.priority < priority) {
            iterator.previous();
            iterator.add(node);
            return true;
        }
    }
    mList.addLast(node);
    return true;
}
 
源代码8 项目: rapidminer-studio   文件: IteratingGSS.java
/**
 * Prunes the given list of hypothesis. All hypothesis with an upper utility bound less than the
 * parameter minUtility is pruned.
 */
public LinkedList<Hypothesis> prune(LinkedList<Hypothesis> hypoList, double minUtility, double totalWeight,
		double totalPositiveWeight, double delta_p) {
	double delta_hp = delta_p / hypoList.size();
	ListIterator<Hypothesis> it = hypoList.listIterator();
	while (it.hasNext()) {
		Hypothesis hypo = it.next();
		double upperBound = theUtility.getUpperBound(totalWeight, totalPositiveWeight, hypo, delta_hp);
		if (upperBound < minUtility) {
			it.remove();
		}
	}
	return hypoList;
}
 
源代码9 项目: jbse   文件: State.java
/**
 * Returns the path condition clauses that have been pushed since
 * the last call of {@link #resetLastPathConditionClauses()}. Used to determine
 * how many clauses have not yet been sent to the decision procedure.
 * 
 * @return a read-only {@link Iterable}{@code <}{@link Clause}{@code >} 
 * representing all the {@link Clause}s cumulated in {@code this}. 
 * It is valid until {@code this} is modified, or {@link #resetLastPathConditionClauses()}
 * is invoked.
 */
public Iterable<Clause> getLastPathConditionPushedClauses() {
    return () -> {
        final ListIterator<Clause> it = this.pathCondition.getClauses().listIterator();
        final int fwdEnd = this.pathCondition.getClauses().size() - this.nPushedClauses;
        for (int i = 1; i <= fwdEnd; ++i) {
            it.next();
        }
        return it;
    };
}
 
源代码10 项目: jdk8u60   文件: ReverseState.java
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
源代码11 项目: osmapi   文件: ModificationAwareListTest.java
public void testModificationViaListIteratorRemove()
{
	ListIterator<String> it = list.listIterator();
	it.next();
	it.remove();
	assertTrue(list.isModified());
}
 
源代码12 项目: jcypher   文件: CompareUtil.java
@SuppressWarnings("rawtypes")
public static boolean equalsAddresses(List addresses1, List addresses2) {
	 if (addresses1 == addresses2)
            return true;

        ListIterator e1 = addresses1.listIterator();
        ListIterator e2 = addresses2.listIterator();
        while (e1.hasNext() && e2.hasNext()) {
        	Object o1 = e1.next();
        	Object o2 = e2.next();
            if (!(o1==null ? o2==null : equalsAddress((Address)o1, (Address)o2)))
                return false;
        }
        return !(e1.hasNext() || e2.hasNext());
}
 
源代码13 项目: Aria   文件: 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;
}
 
源代码14 项目: joshua   文件: AlignedSourceTokens.java
/**
 * shifts each item in the LinkedList by <shift>.
 * Only applies to items larger than <start>
 */
void shiftBy(int start, int shift) {
  if (!isFinal && !isNull) {
    final ListIterator<Integer> it = this.listIterator();
    while (it.hasNext()) {
      final int x = it.next();
      if (x > start) {
        it.set(x + shift);
      }
    }
  }
}
 
源代码15 项目: swift-t   文件: ICTree.java
/**
 * Remove statements by object identity
 * @param stmts
 */
public void removeStatements(Set<? extends Statement> stmts) {
  ListIterator<Statement> it = this.statementIterator();
  while (it.hasNext()) {
    Statement stmt = it.next();
    if (stmts.contains(stmt)) {
      it.remove();
    }
  }
}
 
源代码16 项目: jdk8u_jdk   文件: Remove.java
public static
void main(String[] args) {
    LinkedList list = new LinkedList();
    ListIterator e = list.listIterator();
    Object o = new Integer(1);
    e.add(o);
    e.previous();
    e.next();
    e.remove();
    e.add(o);
    if (!o.equals(list.get(0)))
        throw new RuntimeException("LinkedList ListIterator remove failed.");
}
 
源代码17 项目: jphp   文件: ExprGenerator.java
protected void processSwitch(SwitchStmtToken result, ListIterator<Token> iterator){
    analyzer.addScope(false).setLevelForGoto(true);

    result.setValue(getInBraces(BraceExprToken.Kind.SIMPLE, iterator));
    if (result.getValue() == null)
        unexpectedToken(iterator);

    BodyStmtToken body = analyzer.generator(BodyGenerator.class).getToken(
            nextToken(iterator), iterator, false, false, EndswitchStmtToken.class
    );
    List<CaseStmtToken> cases = new ArrayList<CaseStmtToken>();
    for(ExprStmtToken instruction : body.getInstructions()){
        if (instruction.isSingle()){
            Token token = instruction.getSingle();
            if (token instanceof CaseStmtToken){
                cases.add((CaseStmtToken)token);
                if (token instanceof DefaultStmtToken){
                    if (result.getDefaultCase() != null)
                        unexpectedToken(token);
                    result.setDefaultCase((DefaultStmtToken)token);
                }
            } else
                unexpectedToken(token);
        } else
            unexpectedToken(instruction.getSingle());
    }

    if (body.isAlternativeSyntax())
        iterator.next();

    result.setCases(cases);
    result.setLocal(analyzer.removeScope().getVariables());
}
 
/**
 * Releases for normal dispatching to the current focus owner all
 * KeyEvents which were enqueued because of a call to
 * <code>enqueueKeyEvents</code> with the same timestamp and Component.
 * If the given timestamp is less than zero, the outstanding enqueue
 * request for the given Component with the <b>oldest</b> timestamp (if
 * any) should be cancelled.
 *
 * @param after the timestamp specified in the call to
 *        <code>enqueueKeyEvents</code>, or any value &lt; 0
 * @param untilFocused the Component specified in the call to
 *        <code>enqueueKeyEvents</code>
 * @see #enqueueKeyEvents
 * @see #discardKeyEvents
 */
protected synchronized void dequeueKeyEvents(long after,
                                             Component untilFocused) {
    if (untilFocused == null) {
        return;
    }

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

    TypeAheadMarker marker;
    ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator
        ((after >= 0) ? typeAheadMarkers.size() : 0);

    if (after < 0) {
        while (iter.hasNext()) {
            marker = iter.next();
            if (marker.untilFocused == untilFocused)
            {
                iter.remove();
                return;
            }
        }
    } else {
        while (iter.hasPrevious()) {
            marker = iter.previous();
            if (marker.untilFocused == untilFocused &&
                marker.after == after)
            {
                iter.remove();
                return;
            }
        }
    }
}
 
源代码19 项目: jphp   文件: ConstGenerator.java
@Override
@SuppressWarnings("unchecked")
public ConstStmtToken getToken(Token current, ListIterator<Token> iterator) {
    if (current instanceof ConstStmtToken){
        ConstStmtToken result = (ConstStmtToken)current;

        Token prev = null;
        if (analyzer.getClazz() == null)
            result.setNamespace(analyzer.getNamespace());

        while (true) {
            Token next = analyzer.getClazz() == null ? nextToken(iterator) : nextTokenSensitive(iterator, ClassStmtToken.class);

            if (next instanceof NameToken){
                if (next instanceof FulledNameToken && !((FulledNameToken) next).isProcessed(NamespaceUseStmtToken.UseType.CONSTANT))
                    unexpectedToken(next, TokenType.T_STRING);

                Token token = nextToken(iterator);
                if (!(token instanceof AssignExprToken))
                    unexpectedToken(token, "=");

                ExprStmtToken value = analyzer.generator(SimpleExprGenerator.class)
                    .getToken(nextToken(iterator), iterator, Separator.COMMA_OR_SEMICOLON, null);
                if (!isBreak(iterator.previous())){
                    iterator.next();
                }
                if (value == null)
                    unexpectedToken(iterator.previous());

                result.add((NameToken)next, value);
            } else if (next instanceof CommaToken){
                if (prev instanceof CommaToken)
                    unexpectedToken(next);
                prev = next;
            } else if (isBreak(next)){
                break;
            } else
                unexpectedToken(next, TokenType.T_STRING);
        }
        return result;
    }
    return null;
}
 
源代码20 项目: onos   文件: BgpPrefixLSIdentifier.java
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    int result = this.localNodeDescriptors.compareTo(((BgpPrefixLSIdentifier) o).localNodeDescriptors);
    boolean tlvFound = false;
    if (result != 0) {
        return result;
    } else {
        int countOtherSubTlv = ((BgpPrefixLSIdentifier) o).prefixDescriptor.size();
        int countObjSubTlv = prefixDescriptor.size();
        if (countOtherSubTlv != countObjSubTlv) {
            if (countOtherSubTlv > countObjSubTlv) {
                return 1;
            } else {
                return -1;
            }
        }

        ListIterator<BgpValueType> listIterator = prefixDescriptor.listIterator();
        while (listIterator.hasNext()) {
            BgpValueType tlv1 = listIterator.next();
            for (BgpValueType tlv : ((BgpPrefixLSIdentifier) o).prefixDescriptor) {
                if (tlv.getType() == tlv1.getType()) {
                    result = prefixDescriptor.get(prefixDescriptor.indexOf(tlv1)).compareTo(
                            ((BgpPrefixLSIdentifier) o).prefixDescriptor
                                    .get(((BgpPrefixLSIdentifier) o).prefixDescriptor.indexOf(tlv)));
                    if (result != 0) {
                        return result;
                    }
                    tlvFound = true;
                    break;
                }
            }
            if (!tlvFound) {
                return 1;
            }
        }
    }
    return 0;
}