List of usage examples for com.google.common.collect Iterables concat
public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> inputs)
From source file:cc.kave.commons.pointsto.evaluation.cv.StratifiedMethodsCVFoldBuilder.java
@Override public List<List<Usage>> createFolds(Map<ProjectIdentifier, List<Usage>> projectUsages) { shuffleUsages(projectUsages.values()); Map<ICoReMethodName, Integer> methods = countMethods(Iterables.concat(projectUsages.values())); EnumeratedDistribution<ICoReMethodName> distribution = buildDistribution(methods); MethodRegistry registry = new MethodRegistry(Iterables.concat(projectUsages.values()), methods.size()); List<List<Usage>> folds = new ArrayList<>(numFolds); int avgFoldSize = calcAvgFoldSize(projectUsages.values()); for (int f = 0; f < numFolds - 1; ++f) { List<Usage> fold = new ArrayList<>(avgFoldSize); folds.add(fold);// w w w.j av a 2 s. c o m for (int i = 0; i < avgFoldSize; ++i) { ICoReMethodName method; Usage usage; do { method = distribution.sample(); usage = registry.next(method); } while (usage == null); fold.add(usage); } } folds.add(registry.remaining()); return folds; }
From source file:org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues.java
@Override public Set<String> get() { Collection<Supplier<Set<String>>> zones = regionIdToZoneIdsSupplier.get().values(); return ImmutableSet .copyOf(Iterables.concat(Iterables.transform(zones, Suppliers.<Set<String>>supplierFunction()))); }
From source file:org.jclouds.cloudstack.suppliers.GetCurrentUser.java
@Override public User get() { Iterable<User> users = Iterables.concat(client.getAccountClient().listAccounts()); Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(creds.get().identity); User currentUser = null;//w w w . j a v a 2s. c om try { currentUser = Iterables.find(users, apiKeyMatches); } catch (NoSuchElementException e) { throw new NoSuchElementException( String.format("none of the following users match %s: %s", apiKeyMatches, users)); } return currentUser; }
From source file:codecrafter47.bungeetablistplus.managers.PlayerManagerImpl.java
public PlayerManagerImpl(BungeeTabListPlus plugin, Collection<IPlayerProvider> playerProviders, ProxiedPlayer viewer) {/*ww w. j ava 2 s. c o m*/ this.viewer = viewer; this.players = ImmutableList .copyOf(Iterables.concat(Collections2.transform(playerProviders, IPlayerProvider::getPlayers))); includeSpectators = plugin.getConfig().showPlayersInGamemode3; canSeeHiddenPlayers = plugin.getPermissionManager().hasPermission(viewer, "bungeetablistplus.seevanished"); }
From source file:org.jclouds.trmk.vcloud_0_8.functions.AllCatalogItemsInOrg.java
@Override public Iterable<? extends CatalogItem> apply(Org from) { return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from), new Function<Catalog, Iterable<? extends CatalogItem>>() { @Override/*ww w .j a v a 2 s .c om*/ public Iterable<? extends CatalogItem> apply(Catalog from) { return allCatalogItemsInCatalog.apply(from); } })); }
From source file:org.vclipse.constraint.scoping.ConstraintScopeProvider.java
IScope scope_ShortVarDefinition_ref(ConstraintSource context, EReference ref) { return Scopes.scopeFor(Iterables.concat(Iterables.transform(context.getObjects(), new Function<ConstraintObject, Iterable<ShortVarDefinition>>() { public Iterable<ShortVarDefinition> apply(ConstraintObject constraintObject) { return constraintObject.getShortVars(); }//from w w w . j a va2 s. c o m }))); }
From source file:com.metamx.collections.spatial.RTreeUtils.java
public static Iterable<ImmutablePoint> depthFirstSearch(ImmutableNode node) { if (node.isLeaf()) { return Iterables.transform(node.getChildren(), new Function<ImmutableNode, ImmutablePoint>() { @Override/* ww w .j a va 2 s . c om*/ public ImmutablePoint apply(ImmutableNode tNode) { return new ImmutablePoint(tNode); } }); } else { return Iterables.concat(Iterables.transform( node.getChildren(), new Function<ImmutableNode, Iterable<ImmutablePoint>>() { @Override public Iterable<ImmutablePoint> apply(ImmutableNode child) { return depthFirstSearch(child); } })); } }
From source file:org.polarsys.reqcycle.types.impl.TypesManager.java
@Override public IType getType(final String id) { IType result = allTypes.get(id);//from w ww . ja v a2 s.co m if (result == null) { result = Iterables.find(Iterables.concat(Iterables.transform(providers, new ProviderToITypes())), new Predicate<IType>() { public boolean apply(IType t) { return id.equals(t.getId()); } }, null); } return result; }
From source file:com.palantir.common.collect.IterableView.java
public IterableView<T> concat(Iterable<? extends T>... inputs) { return of(Iterables.concat(Lists.asList(delegate(), inputs))); }
From source file:com.github.larsq.support.ClassStructureWalker.java
public <T> Iterable<T> traverseClassStructure(Function<Class<?>, Iterable<T>> fn) { List<Iterable<T>> listOfIterables = new ArrayList<>(); Set<Class<?>> set = buildClassSet(startAt); set.stream().map(fn).filter(Predicates.Iterables.isNonEmpty()).forEach(listOfIterables::add); return Iterables.concat(listOfIterables); }