@Override public List<Pipe<M, M>> subList(int fromIndex, int toIndex) { return pipeList.subList(fromIndex, toIndex); } }
public static Class<?> resolveClassOf(final Class element) throws ClassNotFoundException { Class<?> cursor = element; LinkedList<String> ognl = Lists.newLinkedList(); while (cursor != null) { ognl.addFirst(cursor.getSimpleName()); cursor = cursor.getDeclaringClass(); } String classOgnl = Joiner.on(".").join(ognl.subList(1, ognl.size())).replace(".$", "$"); return Class.forName(classOgnl); }
public static Class<?> resolveClassOf(final Class element) throws ClassNotFoundException { Class<?> cursor = element; LinkedList<String> ognl = Lists.newLinkedList(); while (cursor != null) { ognl.addFirst(cursor.getSimpleName()); cursor = cursor.getDeclaringClass(); } String classOgnl = Joiner.on(".").join(ognl.subList(1, ognl.size())).replace(".$", "$"); return Class.forName(classOgnl); }
private String computePath(T node) { StringBuilder sb = new StringBuilder(); for (T t : this.nodesList.subList(this.nodesList.indexOf(node), this.nodesList.size())) { sb.append(t).append(" -> "); } sb.append(node); return sb.toString(); } }
public static <T> T kthRecursive(final LinkedList<T> list, final int k) { if (k == 0) { return list.getFirst(); } return kthRecursive(new LinkedList<>(list.subList(1, list.size())), k - 1); }
public static <T> T secondLastRecursion(LinkedList<T> list) { if (list.size() < 2) { throw new NoSuchElementException("Can't find secondLast element from a list with less than 2 elements"); } if (list.size() == 2) { return list.getFirst(); } return secondLastRecursion(new LinkedList<>(list.subList(1, list.size()))); } }
/** * This method will be called when an edge leading to given vertex was added and we want to check if introduction of * this edge has not resulted in apparition of cycle in the graph * * @param vertex * @param vertexStateMap * @return */ public static List<String> introducesCycle( final Vertex vertex, final Map<Vertex, Integer> vertexStateMap ) { final LinkedList<String> cycleStack = new LinkedList<String>(); final boolean hasCycle = dfsVisit( vertex, cycleStack, vertexStateMap ); if ( hasCycle ) { // we have a situation like: [b, a, c, d, b, f, g, h]. // Label of Vertex which introduced the cycle is at the first position in the list // We have to find second occurrence of this label and use its position in the list // for getting the sublist of vertex labels of cycle participants // // So in our case we are searching for [b, a, c, d, b] final String label = cycleStack.getFirst(); final int pos = cycleStack.lastIndexOf( label ); final List<String> cycle = cycleStack.subList( 0, pos + 1 ); Collections.reverse( cycle ); return cycle; } return null; }
public static void main(String[] args) throws Exception { String datapath = "../data"; FNLPCorpus corpus = new FNLPCorpus(); corpus.read(datapath + "/FNLPDATA/WeiboFTB(v1.0).dat", null); System.out.println(corpus.getDocumenNum()); System.out.println(corpus.getSentenceNum()); System.out.println(corpus.getAllPOS()); FNLPDoc doc = corpus.docs.get(0); List<FNLPSent> train = doc.sentences.subList(0, 3000); List<FNLPSent> test = doc.sentences.subList(3000,doc.sentences.size()); doc.sentences = new LinkedList<FNLPSent>(); doc.sentences.addAll(train); corpus.writeOne(datapath + "/FNLPDATA/WeiboFTB(v1.0)-train.dat"); System.out.println(corpus.getSentenceNum()); System.out.println(corpus.getAllPOS().size()); doc.sentences = new LinkedList<FNLPSent>(); doc.sentences.addAll(test); corpus.writeOne(datapath + "/FNLPDATA/WeiboFTB(v1.0)-test.dat"); System.out.println(corpus.getSentenceNum()); System.out.println(corpus.getAllPOS().size()); }
body = new LinkedList<>(body.subList(0, body.size() - 1));
delimQueue.removeAll(delimQueue.subList(replaceIdx, delimQueue.size()));
inSpeech = true; outputQueue.add(new SpeechStartSignal(cdata.getCollectTime() - speechLeader - startSpeechFrames)); outputQueue.addAll(inputQueue.subList( Math.max(0, inputQueue.size() - startSpeechFrames - speechLeaderFrames), inputQueue.size())); inputQueue.clear();
try { if (args.get(0).equals("-list")) { return listSpanReceivers(args.subList(1, args.size())); } else if (args.get(0).equals("-add")) { return addSpanReceiver(args.subList(1, args.size())); } else if (args.get(0).equals("-remove")) { return removeSpanReceiver(args.subList(1, args.size())); } else { System.err.println("Unrecognized tracing command: " + args.get(0));
public List<Article> getArticles() { if (articles.size() > MAX_ARTICLE_COUNT) { return articles.subList(0, MAX_ARTICLE_COUNT); } else { return articles; } }
public List<MpArticle> getArticles() { if (articles.size() > MAX_ARTICLE_COUNT) { return articles.subList(0, MAX_ARTICLE_COUNT); } else { return articles; } }
@Override public CtPath relativePath(CtElement parent) { List<CtElement> roots = new ArrayList<>(); roots.add(parent); int index = 0; for (CtPathElement pathEl : getElements()) { if (pathEl.getElements(roots).size() > 0) { break; } index++; } CtPathImpl result = new CtPathImpl(); result.elements = new LinkedList<>(elements.subList(index, elements.size())); return result; }
ListUtils.kernelQ(buffer, buffer.subList(0, 1), sdBuffer.subList(0, 1)); ListUtils.subtractQ(preKernelSum, preRemovedValues); LinkedList<Float> midExchangedValues = ListUtils.kernelQ(buffer, buffer.subList(preWindowSize, preWindowSize + 1), sdBuffer.subList(preWindowSize, preWindowSize + 1)); ListUtils.addQ(preKernelSum, midExchangedValues); ListUtils.maxQ(preKernelSum.subList(preWindowSize, preWindowSize + postWindowSize), eps); LinkedList<Float> postDensity = ListUtils.maxQ(postKernelSum.subList(preWindowSize, preWindowSize + postWindowSize), eps); tempQ1.addAll(preKernelSum.subList(0, preWindowSize)); tempQ2.clear(); tempQ2.add(1.0F / preWindowSize); levelThreshold = (float) (-Math.log(levelSet) - Math.log(2 * Math.PI) / 2 - ListUtils.sumLog(sdBuffer .subList(preWindowSize, preWindowSize + postWindowSize)) / postWindowSize); / postWindowSize + Math.log(levelSet * Math.sqrt(2 * Math.PI)) + ListUtils.sumLog(sdBuffer .subList(preWindowSize, preWindowSize + postWindowSize)) / postWindowSize);
adapter.stop(); synchronized (triggerPeriods) { assertThat(triggerPeriods.subList(0, 5), contains(10L, 12L, 11L, 12L, 11L));
adapter.stop(); synchronized (overridePresent) { assertThat(overridePresent.subList(0, 5), contains(null, override, null, override, null));
public NodePath splitAt(int splitIndex, PCollectionImpl<?> newHead) { NodePath top = new NodePath(); for (int i = 0; i <= splitIndex; i++) { top.path.add(path.get(i)); } LinkedList<PCollectionImpl<?>> nextPath = Lists.newLinkedList(); nextPath.add(newHead); nextPath.addAll(path.subList(splitIndex + 1, path.size())); path = nextPath; return top; } }
public NodePath splitAt(int splitIndex, PCollectionImpl<?> newHead) { NodePath top = new NodePath(); for (int i = 0; i <= splitIndex; i++) { top.path.add(path.get(i)); } LinkedList<PCollectionImpl<?>> nextPath = Lists.newLinkedList(); nextPath.add(newHead); nextPath.addAll(path.subList(splitIndex + 1, path.size())); path = nextPath; return top; }