当前位置: 首页>>代码示例>>Java>>正文


Java ListIterator.add方法代码示例

本文整理汇总了Java中java.util.ListIterator.add方法的典型用法代码示例。如果您正苦于以下问题:Java ListIterator.add方法的具体用法?Java ListIterator.add怎么用?Java ListIterator.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ListIterator的用法示例。


在下文中一共展示了ListIterator.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addToExpiryList

import java.util.ListIterator; //导入方法依赖的package包/类
private synchronized void addToExpiryList(HttpConnection conn) {
    long now = System.currentTimeMillis() / 1000;
    long then = now + KEEP_ALIVE;
    if (expiryList.isEmpty()) {
        CacheCleaner cleaner = new CacheCleaner(this);
        if (this.cleanerRef.compareAndSet(null, cleaner)) {
            cleaner.start();
        }
        expiryList.add(new ExpiryEntry(conn, then));
        return;
    }

    ListIterator<ExpiryEntry> li = expiryList.listIterator();
    while (li.hasNext()) {
        ExpiryEntry entry = li.next();

        if (then > entry.expiry) {
            li.previous();
            // insert here
            li.add(new ExpiryEntry(conn, then));
            return;
        }
    }
    // first element of list
    expiryList.add(new ExpiryEntry(conn, then));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConnectionPool.java

示例2: merge

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:31,代码来源:MergeUtil.java

示例3: match

import java.util.ListIterator; //导入方法依赖的package包/类
private void match(ListIterator<Match<T>> lit) {
	Match<T> m = lit.next();
	State<T> state = m.getState();
	m.setMatched(false);
	match(lit, m, state);
	if (skipSearch) {
		if (m.isMatched())
			lit.add(m.spawn(state));
		else if (state == trie.getRoot())
			lit.remove();
	}
	else {
		if (!m.isMatched())
			lit.remove();
	}
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:17,代码来源:Matcher.java

示例4: put

import java.util.ListIterator; //导入方法依赖的package包/类
public synchronized void put (String pkey, AuthCacheValue value) {
    LinkedList<AuthCacheValue> list = hashtable.get (pkey);
    String skey = value.getPath();
    if (list == null) {
        list = new LinkedList<AuthCacheValue>();
        hashtable.put(pkey, list);
    }
    // Check if the path already exists or a super-set of it exists
    ListIterator<AuthCacheValue> iter = list.listIterator();
    while (iter.hasNext()) {
        AuthenticationInfo inf = (AuthenticationInfo)iter.next();
        if (inf.path == null || inf.path.startsWith (skey)) {
            iter.remove ();
        }
    }
    iter.add(value);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AuthCacheImpl.java

示例5: diff_lineMode

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:70,代码来源:diff_match_patch.java

示例6: parseData

import java.util.ListIterator; //导入方法依赖的package包/类
private void parseData(Segment newSeg) {
    long sn = newSeg.sn;

    if (itimediff(sn, rcvNxt + rcvWnd) >= 0 || itimediff(sn, rcvNxt) < 0) {
        newSeg.recycle(true);
        return;
    }

    boolean repeat = false;
    boolean findPos = false;
    ListIterator<Segment> listItr = null;
    if (rcvBuf.size() > 0) {
        listItr = rcvBufItr.rewind(rcvBuf.size());
        while (listItr.hasPrevious()) {
            Segment seg = listItr.previous();
            if (seg.sn == sn) {
                repeat = true;
                break;
            }
            if (itimediff(sn, seg.sn) > 0) {
                findPos = true;
                break;
            }
        }
    }

    if (repeat) {
        newSeg.recycle(true);
    } else if (listItr == null) {
        rcvBuf.add(newSeg);
    } else {
        if (findPos) {
            listItr.next();
        }
        listItr.add(newSeg);
    }

    // move available data from rcv_buf -> rcv_queue
    moveRcvData(); // Invoke the method only if the segment is not repeat?
}
 
开发者ID:szhnet,项目名称:kcp-netty,代码行数:41,代码来源:Kcp.java

示例7: testAdd

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * Test of add method, of class TreeListIterator.
 */
@Test(expected = UnsupportedOperationException.class)
public void testAdd() {
    ListIterator<TreeNode> treeListIterator2 = new TreeListIterator(tree2);
    treeListIterator2.next();
    treeListIterator2.add(null);
}
 
开发者ID:miyagilabs,项目名称:Blindfold,代码行数:10,代码来源:TreeListIteratorTest.java

示例8: diff_lineMode

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:70,代码来源:diff_match_patch.java

示例9: transferListIteratorIndirect

import java.util.ListIterator; //导入方法依赖的package包/类
private String transferListIteratorIndirect(String str) {
    List<String> list = new LinkedList<String>();
    // not able to transfer this, set as UNKNOWN even if str is SAFE
    ListIterator<String> listIterator = list.listIterator();
    listIterator.add(str);
    return list.get(0);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:8,代码来源:CommandInjection.java

示例10: diff_lineMode

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:68,代码来源:DiffMatchPatch.java

示例11: decorateResultForIndexMode

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * 为了索引模式修饰结果
 * 
 * @param vertexList
 * @param wordNetAll
 */
protected static List<Term> decorateResultForIndexMode(
		List<Vertex> vertexList, WordNet wordNetAll) {
	List<Term> termList = new LinkedList<Term>();
	int line = 1;
	ListIterator<Vertex> listIterator = vertexList.listIterator();
	listIterator.next();
	int length = vertexList.size() - 2;
	for (int i = 0; i < length; ++i) {
		Vertex vertex = listIterator.next();
		Term termMain = convert(vertex);
		termList.add(termMain);
		termMain.offset = line - 1;
		if (vertex.realWord.length() > 2) {
			// 过长词所在的行
			int currentLine = line;
			while (currentLine < line + vertex.realWord.length()) {
				List<Vertex> vertexListCurrentLine = wordNetAll
						.get(currentLine); // 这一行的词
				for (Vertex smallVertex : vertexListCurrentLine) // 这一行的短词
				{
					if (((termMain.nature == Nature.mq && smallVertex
							.hasNature(Nature.q)) || smallVertex.realWord
							.length() > 1)
							&& smallVertex != vertex) {
						listIterator.add(smallVertex);
						Term termSub = convert(smallVertex);
						termSub.offset = currentLine - 1;
						termList.add(termSub);
					}
				}
				++currentLine;
			}
		}
		line += vertex.realWord.length();
	}

	return termList;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:45,代码来源:WordBasedGenerativeModelSegment.java

示例12: upsertHint

import java.util.ListIterator; //导入方法依赖的package包/类
private void upsertHint(Credential credential) throws IOException {
    CredentialMeta meta = readCredentialMeta();

    // create a copy of the hints list for modification
    List<AccountHint> hints = new ArrayList<>(readCredentialMeta().getHintsList());

    ListIterator<AccountHint> hintIter = hints.listIterator();
    boolean found = false;
    while (!found && hintIter.hasNext()) {
        AccountHint existingHint = hintIter.next();

        if (existingHint.getIdentifier().equals(credential.getId())
                && existingHint.getAuthMethod().equals(credential.getAuthMethod())
                && CredentialQualityScore.getScore(existingHint)
                        <= CredentialQualityScore.getScore(credential)) {
            hintIter.remove();
            hintIter.add(convertCredentialToHint(credential));
            found = true;
        }
    }

    if (!found) {
        hintIter.add(convertCredentialToHint(credential));
    }

    writeCredentialMeta(meta.toBuilder()
            .clearHints()
            .addAllHints(hints)
            .build());
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:31,代码来源:CredentialStorage.java

示例13: createSuites

import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public Suites createSuites(OptionValues options) {
    Suites suites = super.createSuites(options);

    ListIterator<BasePhase<? super LowTierContext>> findPhase = suites.getLowTier().findPhase(FixReadsPhase.class);
    if (findPhase == null) {
        findPhase = suites.getLowTier().findPhase(ExpandLogicPhase.class);
    }
    findPhase.add(new AddressLoweringPhase(addressLowering));

    return suites;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:AddressLoweringHotSpotSuitesProvider.java

示例14: createSuites

import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public Suites createSuites(OptionValues options) {
    Suites ret = defaultSuitesCreator.createSuites(options);

    if (ImmutableCode.getValue(options)) {
        // lowering introduces class constants, therefore it must be after lowering
        ret.getHighTier().appendPhase(new LoadJavaMirrorWithKlassPhase(config));
        if (VerifyPhases.getValue(options)) {
            ret.getHighTier().appendPhase(new AheadOfTimeVerificationPhase());
        }
        if (GeneratePIC.getValue(options)) {
            ListIterator<BasePhase<? super HighTierContext>> highTierLowering = ret.getHighTier().findPhase(LoweringPhase.class);
            highTierLowering.previous();
            highTierLowering.add(new EliminateRedundantInitializationPhase());
            if (HotSpotAOTProfilingPlugin.Options.TieredAOT.getValue(options)) {
                highTierLowering.add(new FinalizeProfileNodesPhase(HotSpotAOTProfilingPlugin.Options.TierAInvokeInlineeNotifyFreqLog.getValue(options)));
            }
            ListIterator<BasePhase<? super MidTierContext>> midTierLowering = ret.getMidTier().findPhase(LoweringPhase.class);
            midTierLowering.add(new ReplaceConstantNodesPhase());

            // Replace inlining policy
            if (Inline.getValue(options)) {
                ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(InliningPhase.class);
                InliningPhase inlining = (InliningPhase) iter.previous();
                CanonicalizerPhase canonicalizer = inlining.getCanonicalizer();
                iter.set(new InliningPhase(new AOTInliningPolicy(null), canonicalizer));
            }
        }
    }

    ret.getMidTier().appendPhase(new WriteBarrierAdditionPhase(config));
    if (VerifyPhases.getValue(options)) {
        ret.getMidTier().appendPhase(new WriteBarrierVerificationPhase(config));
    }

    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:HotSpotSuitesProvider.java

示例15: testListIteratorSetFail

import java.util.ListIterator; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testListIteratorSetFail() {
    List<Integer> list = redisson.getList("list");
    list.add(1);

    ListIterator<Integer> iterator = list.listIterator();

    iterator.next();
    iterator.add(2);
    iterator.set(3);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:RedissonListTest.java


注:本文中的java.util.ListIterator.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。