java.util.LinkedList.subList()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(427)

本文整理了Java中java.util.LinkedList.subList()方法的一些代码示例,展示了LinkedList.subList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.subList()方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:subList

LinkedList.subList介绍

暂无

代码示例

代码示例来源:origin: hankcs/HanLP

  1. @Override
  2. public List<Pipe<M, M>> subList(int fromIndex, int toIndex)
  3. {
  4. return pipeList.subList(fromIndex, toIndex);
  5. }
  6. }

代码示例来源:origin: ronmamo/reflections

  1. public static Class<?> resolveClassOf(final Class element) throws ClassNotFoundException {
  2. Class<?> cursor = element;
  3. LinkedList<String> ognl = Lists.newLinkedList();
  4. while (cursor != null) {
  5. ognl.addFirst(cursor.getSimpleName());
  6. cursor = cursor.getDeclaringClass();
  7. }
  8. String classOgnl = Joiner.on(".").join(ognl.subList(1, ognl.size())).replace(".$", "$");
  9. return Class.forName(classOgnl);
  10. }

代码示例来源:origin: org.reflections/reflections

  1. public static Class<?> resolveClassOf(final Class element) throws ClassNotFoundException {
  2. Class<?> cursor = element;
  3. LinkedList<String> ognl = Lists.newLinkedList();
  4. while (cursor != null) {
  5. ognl.addFirst(cursor.getSimpleName());
  6. cursor = cursor.getDeclaringClass();
  7. }
  8. String classOgnl = Joiner.on(".").join(ognl.subList(1, ognl.size())).replace(".$", "$");
  9. return Class.forName(classOgnl);
  10. }

代码示例来源:origin: apache/incubator-gobblin

  1. private String computePath(T node) {
  2. StringBuilder sb = new StringBuilder();
  3. for (T t : this.nodesList.subList(this.nodesList.indexOf(node), this.nodesList.size())) {
  4. sb.append(t).append(" -> ");
  5. }
  6. sb.append(node);
  7. return sb.toString();
  8. }
  9. }

代码示例来源:origin: shekhargulati/99-problems

  1. public static <T> T kthRecursive(final LinkedList<T> list, final int k) {
  2. if (k == 0) {
  3. return list.getFirst();
  4. }
  5. return kthRecursive(new LinkedList<>(list.subList(1, list.size())), k - 1);
  6. }

代码示例来源:origin: shekhargulati/99-problems

  1. public static <T> T secondLastRecursion(LinkedList<T> list) {
  2. if (list.size() < 2) {
  3. throw new NoSuchElementException("Can't find secondLast element from a list with less than 2 elements");
  4. }
  5. if (list.size() == 2) {
  6. return list.getFirst();
  7. }
  8. return secondLastRecursion(new LinkedList<>(list.subList(1, list.size())));
  9. }
  10. }

代码示例来源:origin: org.codehaus.plexus/plexus-utils

  1. /**
  2. * This method will be called when an edge leading to given vertex was added and we want to check if introduction of
  3. * this edge has not resulted in apparition of cycle in the graph
  4. *
  5. * @param vertex
  6. * @param vertexStateMap
  7. * @return
  8. */
  9. public static List<String> introducesCycle( final Vertex vertex, final Map<Vertex, Integer> vertexStateMap )
  10. {
  11. final LinkedList<String> cycleStack = new LinkedList<String>();
  12. final boolean hasCycle = dfsVisit( vertex, cycleStack, vertexStateMap );
  13. if ( hasCycle )
  14. {
  15. // we have a situation like: [b, a, c, d, b, f, g, h].
  16. // Label of Vertex which introduced the cycle is at the first position in the list
  17. // We have to find second occurrence of this label and use its position in the list
  18. // for getting the sublist of vertex labels of cycle participants
  19. //
  20. // So in our case we are searching for [b, a, c, d, b]
  21. final String label = cycleStack.getFirst();
  22. final int pos = cycleStack.lastIndexOf( label );
  23. final List<String> cycle = cycleStack.subList( 0, pos + 1 );
  24. Collections.reverse( cycle );
  25. return cycle;
  26. }
  27. return null;
  28. }

代码示例来源:origin: FudanNLP/fnlp

  1. public static void main(String[] args) throws Exception {
  2. String datapath = "../data";
  3. FNLPCorpus corpus = new FNLPCorpus();
  4. corpus.read(datapath + "/FNLPDATA/WeiboFTB(v1.0).dat", null);
  5. System.out.println(corpus.getDocumenNum());
  6. System.out.println(corpus.getSentenceNum());
  7. System.out.println(corpus.getAllPOS());
  8. FNLPDoc doc = corpus.docs.get(0);
  9. List<FNLPSent> train = doc.sentences.subList(0, 3000);
  10. List<FNLPSent> test = doc.sentences.subList(3000,doc.sentences.size());
  11. doc.sentences = new LinkedList<FNLPSent>();
  12. doc.sentences.addAll(train);
  13. corpus.writeOne(datapath + "/FNLPDATA/WeiboFTB(v1.0)-train.dat");
  14. System.out.println(corpus.getSentenceNum());
  15. System.out.println(corpus.getAllPOS().size());
  16. doc.sentences = new LinkedList<FNLPSent>();
  17. doc.sentences.addAll(test);
  18. corpus.writeOne(datapath + "/FNLPDATA/WeiboFTB(v1.0)-test.dat");
  19. System.out.println(corpus.getSentenceNum());
  20. System.out.println(corpus.getAllPOS().size());
  21. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. body = new LinkedList<>(body.subList(0, body.size() - 1));

代码示例来源:origin: apache/ignite

  1. delimQueue.removeAll(delimQueue.subList(replaceIdx, delimQueue.size()));

代码示例来源:origin: cmusphinx/sphinx4

  1. inSpeech = true;
  2. outputQueue.add(new SpeechStartSignal(cdata.getCollectTime() - speechLeader - startSpeechFrames));
  3. outputQueue.addAll(inputQueue.subList(
  4. Math.max(0, inputQueue.size() - startSpeechFrames - speechLeaderFrames), inputQueue.size()));
  5. inputQueue.clear();

代码示例来源:origin: org.apache.hadoop/hadoop-common

  1. try {
  2. if (args.get(0).equals("-list")) {
  3. return listSpanReceivers(args.subList(1, args.size()));
  4. } else if (args.get(0).equals("-add")) {
  5. return addSpanReceiver(args.subList(1, args.size()));
  6. } else if (args.get(0).equals("-remove")) {
  7. return removeSpanReceiver(args.subList(1, args.size()));
  8. } else {
  9. System.err.println("Unrecognized tracing command: " + args.get(0));

代码示例来源:origin: foxinmy/weixin4j

  1. public List<Article> getArticles() {
  2. if (articles.size() > MAX_ARTICLE_COUNT) {
  3. return articles.subList(0, MAX_ARTICLE_COUNT);
  4. } else {
  5. return articles;
  6. }
  7. }

代码示例来源:origin: foxinmy/weixin4j

  1. public List<MpArticle> getArticles() {
  2. if (articles.size() > MAX_ARTICLE_COUNT) {
  3. return articles.subList(0, MAX_ARTICLE_COUNT);
  4. } else {
  5. return articles;
  6. }
  7. }

代码示例来源:origin: INRIA/spoon

  1. @Override
  2. public CtPath relativePath(CtElement parent) {
  3. List<CtElement> roots = new ArrayList<>();
  4. roots.add(parent);
  5. int index = 0;
  6. for (CtPathElement pathEl : getElements()) {
  7. if (pathEl.getElements(roots).size() > 0) {
  8. break;
  9. }
  10. index++;
  11. }
  12. CtPathImpl result = new CtPathImpl();
  13. result.elements = new LinkedList<>(elements.subList(index, elements.size()));
  14. return result;
  15. }

代码示例来源:origin: yahoo/egads

  1. ListUtils.kernelQ(buffer, buffer.subList(0, 1), sdBuffer.subList(0, 1));
  2. ListUtils.subtractQ(preKernelSum, preRemovedValues);
  3. LinkedList<Float> midExchangedValues =
  4. ListUtils.kernelQ(buffer, buffer.subList(preWindowSize, preWindowSize + 1),
  5. sdBuffer.subList(preWindowSize, preWindowSize + 1));
  6. ListUtils.addQ(preKernelSum, midExchangedValues);
  7. ListUtils.maxQ(preKernelSum.subList(preWindowSize, preWindowSize + postWindowSize), eps);
  8. LinkedList<Float> postDensity =
  9. ListUtils.maxQ(postKernelSum.subList(preWindowSize, preWindowSize + postWindowSize), eps);
  10. tempQ1.addAll(preKernelSum.subList(0, preWindowSize));
  11. tempQ2.clear();
  12. tempQ2.add(1.0F / preWindowSize);
  13. levelThreshold =
  14. (float) (-Math.log(levelSet) - Math.log(2 * Math.PI) / 2 - ListUtils.sumLog(sdBuffer
  15. .subList(preWindowSize, preWindowSize + postWindowSize)) / postWindowSize);
  16. / postWindowSize
  17. + Math.log(levelSet * Math.sqrt(2 * Math.PI)) + ListUtils.sumLog(sdBuffer
  18. .subList(preWindowSize, preWindowSize + postWindowSize)) / postWindowSize);

代码示例来源:origin: spring-projects/spring-integration

  1. adapter.stop();
  2. synchronized (triggerPeriods) {
  3. assertThat(triggerPeriods.subList(0, 5), contains(10L, 12L, 11L, 12L, 11L));

代码示例来源:origin: spring-projects/spring-integration

  1. adapter.stop();
  2. synchronized (overridePresent) {
  3. assertThat(overridePresent.subList(0, 5), contains(null, override, null, override, null));

代码示例来源:origin: cloudera/crunch

  1. public NodePath splitAt(int splitIndex, PCollectionImpl<?> newHead) {
  2. NodePath top = new NodePath();
  3. for (int i = 0; i <= splitIndex; i++) {
  4. top.path.add(path.get(i));
  5. }
  6. LinkedList<PCollectionImpl<?>> nextPath = Lists.newLinkedList();
  7. nextPath.add(newHead);
  8. nextPath.addAll(path.subList(splitIndex + 1, path.size()));
  9. path = nextPath;
  10. return top;
  11. }
  12. }

代码示例来源:origin: org.apache.crunch/crunch

  1. public NodePath splitAt(int splitIndex, PCollectionImpl<?> newHead) {
  2. NodePath top = new NodePath();
  3. for (int i = 0; i <= splitIndex; i++) {
  4. top.path.add(path.get(i));
  5. }
  6. LinkedList<PCollectionImpl<?>> nextPath = Lists.newLinkedList();
  7. nextPath.add(newHead);
  8. nextPath.addAll(path.subList(splitIndex + 1, path.size()));
  9. path = nextPath;
  10. return top;
  11. }

相关文章