List of usage examples for com.google.common.collect Iterables size
public static int size(Iterable<?> iterable)
From source file:org.caleydo.vis.lineup.internal.ui.ButtonBar.java
public float getMinWidth() { int buttons = Iterables.size(Iterables.filter(this, GLButton.class)); return buttons * (RenderStyle.BUTTON_WIDTH + 1); }
From source file:com.ibm.common.geojson.GeometryCollection.java
public int size() { return Iterables.size(geometries()); }
From source file:com.cognifide.aet.job.common.comparators.accessibility.report.AccessibilityReportGenerator.java
private void invoke() { Iterable<AccessibilityIssue> errors = Iterables.filter(nonExcludedIssues, new IssueTypePredicate(IssueType.ERROR)); errorCount = Iterables.size(errors); warningCount = filterAndCount(!configuration.isShowWarning(), IssueType.WARN); noticeCount = filterAndCount(!configuration.isShowNotice(), IssueType.NOTICE); sortIssues(nonExcludedIssues);/*w ww . ja v a 2s . c om*/ sortIssues(excludedIssues); }
From source file:dagger.internal.codegen.Formatter.java
private void formatIndentedList(StringBuilder builder, int indentLevel, Iterable<? extends T> firstItems, Iterable<? extends T> restOfItems) { for (T item : firstItems) { builder.append('\n'); appendIndent(builder, indentLevel); builder.append(format(item));/* w ww. j a v a 2 s . c o m*/ } int numberOfOtherItems = Iterables.size(restOfItems); if (numberOfOtherItems > 0) { builder.append('\n'); appendIndent(builder, indentLevel); builder.append("and ").append(numberOfOtherItems).append(" other"); } if (numberOfOtherItems > 1) { builder.append('s'); } }
From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java
/** * Tests whether an attribute matches a limit constraint. * * @param attributes Attributes to match against. * @param jobKey Key of the job with the limited constraint. * @param limit Limit value./* w ww. j ava2 s. c o m*/ * @param activeTasks All active tasks in the system. * @param attributeFetcher Interface for fetching attributes for hosts in the system. * @return {@code true} if the limit constraint is satisfied, {@code false} otherwise. */ static boolean matches(final Set<Attribute> attributes, final IJobKey jobKey, int limit, Iterable<IScheduledTask> activeTasks, final AttributeLoader attributeFetcher) { Predicate<IScheduledTask> sameJob = Predicates.compose(Predicates.equalTo(jobKey), Tasks.SCHEDULED_TO_JOB_KEY); Predicate<IScheduledTask> hasAttribute = new Predicate<IScheduledTask>() { @Override public boolean apply(IScheduledTask task) { Iterable<Attribute> hostAttributes = attributeFetcher.apply(task.getAssignedTask().getSlaveHost()); return Iterables.any(hostAttributes, Predicates.in(attributes)); } }; return limit > Iterables.size(Iterables.filter(activeTasks, Predicates.and(sameJob, hasAttribute))); }
From source file:nl.tudelft.graphalytics.giraph.algorithms.lcc.UndirectedLocalClusteringCoefficientComputation.java
@Override public void compute(Vertex<LongWritable, DoubleWritable, NullWritable> vertex, Iterable<LocalClusteringCoefficientMessage> messages) throws IOException { if (getSuperstep() == 0) { // First superstep: create a set of neighbours, for each pair ask if they are connected collectNeighbourSet(vertex.getEdges()); sendConnectionInquiries(vertex.getId().get()); } else if (getSuperstep() == 1) { // Second superstep: for each inquiry reply iff the requested edge exists sendConnectionReplies(vertex.getEdges(), messages); } else if (getSuperstep() == 2) { // Third superstep: compute the ratio of responses to requests double lcc = computeLCC(Iterables.size(vertex.getEdges()), messages); vertex.getValue().set(lcc);// w ww .j a va 2s .c om vertex.voteToHalt(); } }
From source file:org.apache.metron.common.writer.BulkWriterComponent.java
public void error(Throwable e, Iterable<Tuple> tuples) { tuples.forEach(t -> collector.ack(t)); LOG.error("Failing " + Iterables.size(tuples) + " tuples", e); ErrorUtils.handleError(collector, e, Constants.ERROR_STREAM); }
From source file:org.movsim.simulator.roadnetwork.controller.TrafficLights.java
private static boolean networkContainsTrafficlights(RoadNetwork roadNetwork) { for (RoadSegment roadSegment : roadNetwork) { if (Iterables.size(roadSegment.roadObjects().values(RoadObjectType.TRAFFICLIGHT)) > 0) { return true; }/*www . j a v a2 s . c o m*/ } return false; }
From source file:org.jclouds.softlayer.compute.functions.internal.OperatingSystems.java
private static String parseVersion(String version) { if (version.contains("-")) { String rawVersion = version.substring(0, version.lastIndexOf("-")); if (Iterables.size(Splitter.on(".").split(rawVersion)) == 3) { return rawVersion.substring(0, rawVersion.lastIndexOf(".")); } else {/*from w ww. j a v a 2s .c o m*/ return rawVersion; } } else if (version.contains(" ")) { return version.substring(0, version.indexOf(" ")); } else if (version.matches("^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$")) { return version; } return null; }
From source file:com.google.javascript.jscomp.PrebuildAst.java
void prebuild(Iterable<CompilerInput> allInputs) { ThreadFactory threadFactory = new ThreadFactory() { @Override/*from w w w. j a v a2 s . c o m*/ public Thread newThread(Runnable r) { Thread t = new Thread(null, r, "jscompiler-PrebuildAst", CompilerExecutor.COMPILER_STACK_SIZE); t.setDaemon(true); // Do not prevent the JVM from exiting. return t; } }; ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(numParallelThreads, numParallelThreads, Integer.MAX_VALUE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); ListeningExecutorService executorService = MoreExecutors.listeningDecorator(poolExecutor); List<ListenableFuture<?>> futureList = new ArrayList<>(Iterables.size(allInputs)); // TODO(moz): Support canceling all parsing on the first halting error for (final CompilerInput input : allInputs) { futureList.add(executorService.submit(new Runnable() { @Override public void run() { input.getAstRoot(compiler); } })); } poolExecutor.shutdown(); try { Futures.allAsList(futureList).get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }