List of usage examples for com.google.common.collect Iterables skip
public static <T> Iterable<T> skip(final Iterable<T> iterable, final int numberToSkip)
From source file:tedigraphwithgs.TediGraph.java
public void generateTree(Stack s, Graph g) throws IOException { tree = new TreeDecomposition(); TreeNode tn = new TreeNode(); int count = 0; //construct root dengan semua node graph yang tidak diremove pada proses graph reduction for (Node n : g.getEachNode()) { tn.getListVertex().add(n);//w w w. j a v a 2 s.co m } tree.setRoot(tn); //insert root ke list bag pada tree tree.getListBag().add(tn); //iterasi untuk mengeluarkan isi stack while (!s.empty()) { if (tree.getListBag().size() != 0) { //iterasi semua bag yang ada di list bag for (TreeNode treeNode : tree.getListBag()) { //iterasi semua node yang ada pada top stack for (Node n : Iterables.skip(((TreeNode) s.peek()).getListVertex(), 1)) { //jika bag mengandung node yg dimiliki oleh top stack if (treeNode.getListVertex().contains(n)) { count++; } //jika bag memiliki semua node -1 yg ada pada top stack if (count == treeNode.getListVertex().size() - 1) { //set parent ((TreeNode) s.peek()).setParent(treeNode); System.out.println("induk dari " + ((TreeNode) s.peek()).getListVertex() + " adalah " + treeNode.getListVertex()); count = 0; } } count = 0; } } tree.getListBag().add((TreeNode) s.pop()); } }
From source file:org.apache.james.imap.main.PathConverter.java
private MailboxPath buildAbsolutePath(String absolutePath) { char pathDelimiter = ImapSessionUtils.getMailboxSession(session).getPathDelimiter(); List<String> mailboxPathParts = Splitter.on(pathDelimiter).splitToList(absolutePath); String namespace = mailboxPathParts.get(NAMESPACE); String mailboxName = Joiner.on(pathDelimiter).join(Iterables.skip(mailboxPathParts, 1)); return buildMailboxPath(namespace, retrieveUserName(namespace), mailboxName); }
From source file:com.palantir.common.collect.IterableView.java
public IterableView<T> skip(int numberToSkip) { return of(Iterables.skip(delegate(), numberToSkip)); }
From source file:org.onos.yangtools.yang.data.api.StackedYangInstanceIdentifier.java
@Override YangInstanceIdentifier createRelativeIdentifier(final int skipFromRoot) { // TODO: can we optimize this one? return YangInstanceIdentifier.create(Iterables.skip(getPathArguments(), skipFromRoot)); }
From source file:com.github.jsdossier.markdown.TableBlockParser.java
@Override public void parseInlines(InlineParser inlineParser) { Node headNode = new TableHeadNode(); block.appendChild(headNode);/*from ww w . j a v a 2 s . com*/ headNode.appendChild(parseRow(headerRow.toString(), inlineParser)); // The first row of data is always the column alignments, which we've already parsed. Node bodyNode = new TableBodyNode(); block.appendChild(bodyNode); String caption = null; for (CharSequence line : Iterables.skip(rowData, 1)) { Matcher captionMatcher = CAPTION_LINE.matcher(line); if (captionMatcher.matches()) { caption = captionMatcher.group("content").trim(); } else { TableRowNode row = parseRow(line.toString(), inlineParser); bodyNode.appendChild(row); } } if (!isNullOrEmpty(caption)) { TableCaptionNode captionNode = new TableCaptionNode(); headNode.insertBefore(captionNode); inlineParser.parse(caption.trim(), captionNode); } }
From source file:org.apache.solr.analytics.facet.SortableFacet.java
/** * Apply the sorting options to the given facet results. * /*from w ww . j av a 2s. co m*/ * @param facetResults to apply sorting options to * @return the sorted results */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected Iterable<FacetBucket> applyOptions(List<FacetBucket> facetResults) { // Sorting the buckets if a sort specification is provided if (sort == null || facetResults.isEmpty()) { return facetResults; } Comparator comp = sort.getComparator(); Collections.sort(facetResults, comp); Iterable<FacetBucket> facetResultsIter = facetResults; // apply the limit if (sort.getLimit() > 0) { if (sort.getOffset() > 0) { facetResultsIter = Iterables.skip(facetResultsIter, sort.getOffset()); } facetResultsIter = Iterables.limit(facetResultsIter, sort.getLimit()); } else if (sort.getLimit() == 0) { return new LinkedList<FacetBucket>(); } return facetResultsIter; }
From source file:org.vclipse.constraint.scoping.ConstraintScopeProvider.java
private IScope createCsticScope(Iterable<Class> classes) { Class cls = Iterables.getFirst(classes, null); Iterable<Class> restClasses = Iterables.skip(classes, 1); if (cls.getSuperClasses().isEmpty() && Iterables.isEmpty(restClasses)) { return Scopes.scopeFor(cls.getCharacteristics()); } else {//from w w w.j a va2s. c o m return Scopes.scopeFor(cls.getCharacteristics(), createCsticScope(Iterables.concat(cls.getSuperClasses(), restClasses))); } }
From source file:org.apache.james.server.core.configuration.FileConfigurationProvider.java
private HierarchicalConfiguration selectConfigurationPart(List<String> configPathParts, HierarchicalConfiguration config) { return selectHierarchicalConfigPart(config, Iterables.skip(configPathParts, 1)); }
From source file:org.ndgf.endit.StageTask.java
private EnditException throwError(List<String> lines) throws EnditException { String error;//from ww w.java 2s . c o m int errorCode; if (lines.isEmpty()) { errorCode = 1; error = "Endit reported a stage failure without providing a reason."; } else { try { errorCode = Integer.parseInt(lines.get(0)); error = Joiner.on("\n").join(Iterables.skip(lines, 1)); } catch (NumberFormatException e) { errorCode = 1; error = Joiner.on("\n").join(lines); } } throw new EnditException(errorCode, error); }
From source file:org.csanchez.jenkins.plugins.kubernetes.pipeline.EvictingQueue.java
@Override public boolean addAll(Collection<? extends E> collection) { int size = collection.size(); if (size >= maxSize) { clear();/*from w w w. j av a 2 s . c o m*/ return Iterables.addAll(this, Iterables.skip(collection, size - maxSize)); } return standardAddAll(collection); }