List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:com.facebook.buck.rules.coercer.EnvMacroTypeCoercer.java
@Override public EnvMacro coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot, TargetConfiguration targetConfiguration, ImmutableList<String> args) throws CoerceFailedException { Preconditions.checkState(args.size() == 1, String.format("expected a single argument: %s", args)); return EnvMacro.of(args.get(0)); }
From source file:com.facebook.buck.rules.coercer.OutputMacroTypeCoercer.java
@Override public OutputMacro coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot, TargetConfiguration targetConfiguration, ImmutableList<String> args) throws CoerceFailedException { if (args.size() != 1) { throw new CoerceFailedException(String.format("expected exactly one argument (found %d)", args.size())); }/*from w w w . j a va 2s.c o m*/ return OutputMacro.of(args.get(0)); }
From source file:com.facebook.buck.rules.coercer.LocationMacroTypeCoercer.java
@Override public LocationMacro coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot, TargetConfiguration targetConfiguration, ImmutableList<String> args) throws CoerceFailedException { if (args.size() != 1 || args.get(0).isEmpty()) { throw new CoerceFailedException(String.format("expected exactly one argument (found %d)", args.size())); }/*from w w w.j a v a 2s .c om*/ LocationMacro.SplitResult parts = LocationMacro.splitSupplementaryOutputPart(args.get(0)); BuildTarget target = buildTargetTypeCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot, targetConfiguration, parts.target); return LocationMacro.of(target, parts.supplementaryOutput); }
From source file:bots.mctsbot.ai.bots.bot.gametree.mcts.strategies.selection.SampleProportionateSelector.java
@Override public INode select(InnerNode innerNode) { ImmutableList<INode> children = innerNode.getChildren(); int[] cumulSums = new int[children.size()]; int cumulSum = 0; for (int i = 0; i < children.size(); i++) { int nbSamples = children.get(i).getNbSamples(); cumulSum += nbSamples;// w w w .j a v a2 s.c o m cumulSums[i] = cumulSum; } int randVar = random.nextInt(cumulSum); for (int i = 0; i < cumulSums.length; i++) { if (randVar < cumulSums[i]) { return children.get(i); } } return children.get(cumulSums.length - 1); }
From source file:com.skelril.nitro.droptable.roller.SlipperySingleHitDiceRoller.java
@Override public <T extends DropTableEntry> Collection<T> getHits(ImmutableList<T> input, double modifier) { ListIterator<T> it = input.listIterator(input.size()); T cur = null;/*from ww w .ja v a2s . c o m*/ while (it.hasPrevious()) { cur = it.previous(); // Slip through until something which is >= the chance is hit, unless a modifier is applied // this is equivalent to a 1 / chance probability if (cur.getChance() <= Probability.getRandom(modiFunc.apply(cur.getChance(), modifier))) { break; } cur = null; } return cur == null ? Collections.emptySet() : Collections.singleton(cur); }
From source file:org.apache.james.mailetcontainer.impl.matchers.And.java
private Set<MailAddress> computeIntersection(ImmutableList<Set<MailAddress>> individualMatchedResults) { if (individualMatchedResults.size() == 0) { return ImmutableSet.of(); }//from w w w. j a v a 2 s .c o m if (individualMatchedResults.size() == 1) { return individualMatchedResults.get(0); } return Sets.intersection(individualMatchedResults.get(0), computeIntersection(individualMatchedResults.subList(1, individualMatchedResults.size()))); }
From source file:com.github.jasonruckman.sidney.ext.guava.ImmutableListSerializer.java
@Override public void writeValue(ImmutableList<T> value, Contexts.WriteContext context) { context.getMeta().writeRepetitionCount(value.size()); for (T o : value) { contentSerializer.writeValue(o, context); }/*www. ja v a2 s. c o m*/ }
From source file:com.google.devtools.build.lib.syntax.SkylarkCallbackFunction.java
/** * Creates a list of actual arguments that contains the given arguments and all attribute values * required from the specified context.// w w w. j av a2 s .c o m */ private ImmutableList<Object> buildArgumentList(ClassObject ctx, Object... arguments) { Builder<Object> builder = ImmutableList.<Object>builder(); ImmutableList<String> names = getParameterNames(); int requiredParameters = names.size() - arguments.length; for (int pos = 0; pos < requiredParameters; ++pos) { String name = names.get(pos); Object value = ctx.getValue(name); if (value == null) { throw new IllegalArgumentException(ctx.errorMessage(name)); } builder.add(value); } return builder.add(arguments).build(); }
From source file:com.google.template.soy.jbcsrc.restricted.BytecodeUtils.java
private static Expression newMap(Iterable<? extends Expression> keys, Iterable<? extends Expression> values, ConstructorRef constructorRef, Type mapType) { final ImmutableList<Expression> keysCopy = ImmutableList.copyOf(keys); final ImmutableList<Expression> valuesCopy = ImmutableList.copyOf(values); checkArgument(keysCopy.size() == valuesCopy.size()); for (int i = 0; i < keysCopy.size(); i++) { checkArgument(keysCopy.get(i).resultType().getSort() == Type.OBJECT); checkArgument(valuesCopy.get(i).resultType().getSort() == Type.OBJECT); }// w w w . j av a 2s . c o m final Expression construct = constructorRef.construct(constant(hashMapCapacity(keysCopy.size()))); return new Expression(mapType, Feature.NON_NULLABLE) { @Override protected void doGen(CodeBuilder mv) { construct.gen(mv); for (int i = 0; i < keysCopy.size(); i++) { Expression key = keysCopy.get(i); Expression value = valuesCopy.get(i); mv.dup(); key.gen(mv); value.gen(mv); MethodRef.MAP_PUT.invokeUnchecked(mv); mv.pop(); // pop the Object result of map.put } } }; }
From source file:org.xlrnet.tibaija.matchers.EqualsTIListMatcher.java
public boolean matches(Object actualRaw) { ImmutableList<Complex> actualValues = ((Value) actualRaw).list(); if (actualValues.size() != wantedValues.length) return false; for (int i = 0; i < wantedValues.length; i++) { Complex actual = actualValues.get(i); Complex wanted = wantedValues[i]; if (!internalMatchesSingleComplex(actual, wanted)) return false; }//from ww w . j a v a2s.com return true; }