本文整理匯總了Java中com.google.common.collect.Lists.newArrayListWithExpectedSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Lists.newArrayListWithExpectedSize方法的具體用法?Java Lists.newArrayListWithExpectedSize怎麽用?Java Lists.newArrayListWithExpectedSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Lists
的用法示例。
在下文中一共展示了Lists.newArrayListWithExpectedSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectFooterActions
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
protected Collection<Button> collectFooterActions(RenderContext context)
{
List<Button> br = Lists.newArrayListWithExpectedSize(3);
Label saveLabel = LABEL_SAVE;
if( getModel(context).getSchemaId() <= 0 )
{
saveLabel = LABEL_ADD;
br.add(addOnline);
}
getOk().setLabel(context, saveLabel);
br.add(getOk());
return br;
}
示例2: searchRoles
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public List<RoleBean> searchRoles(String query)
{
List<RoleBean> rv = null;
for( RoleBean roleBean : roles.values() )
{
if( TLEPattern.matches(query, roleBean.getName()) )
{
if( rv == null )
{
rv = Lists.newArrayListWithExpectedSize(roles.size());
}
rv.add(roleBean);
}
}
return rv;
}
示例3: buildCartesianProduct
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Sets.cartesianProduct doesn't allow sets that contain null, but we want null to mean
* "don't call the associated CacheBuilder method" - that is, get the default CacheBuilder
* behavior. This method wraps the elements in the input sets (which may contain null) as
* Optionals, calls Sets.cartesianProduct with those, then transforms the result to unwrap
* the Optionals.
*/
private Iterable<List<Object>> buildCartesianProduct(Set<?>... sets) {
List<Set<Optional<?>>> optionalSets = Lists.newArrayListWithExpectedSize(sets.length);
for (Set<?> set : sets) {
Set<Optional<?>> optionalSet =
Sets.newLinkedHashSet(Iterables.transform(set, NULLABLE_TO_OPTIONAL));
optionalSets.add(optionalSet);
}
Set<List<Optional<?>>> cartesianProduct = Sets.cartesianProduct(optionalSets);
return Iterables.transform(cartesianProduct,
new Function<List<Optional<?>>, List<Object>>() {
@Override public List<Object> apply(List<Optional<?>> objs) {
return Lists.transform(objs, OPTIONAL_TO_NULLABLE);
}
});
}
示例4: getRecipes
import com.google.common.collect.Lists; //導入方法依賴的package包/類
protected List<Recipe> getRecipes(FeatureWrapper feature, Collection<Pickle> pickles) {
int pickleCount = pickles.size();
ArrayList<Recipe> recipes = Lists.newArrayListWithExpectedSize(pickleCount);
Set<Integer> pickleLines = Sets.newHashSetWithExpectedSize(pickleCount);
RangeMap<Integer, ScenarioDefinition> rangeMap = getRangeMap(feature);
for (Pickle pickle : pickles) {
List<PickleLocation> locations = pickle.getLocations();
for (PickleLocation location : locations) {
int line = location.getLine();
if (!pickleLines.contains(line)) {
pickleLines.add(line);
Range<Integer> range = Range.singleton(line);
RangeMap<Integer, ScenarioDefinition> subRangeMap = rangeMap.subRangeMap(range);
Map<Range<Integer>, ScenarioDefinition> asMap = subRangeMap.asMapOfRanges();
checkState(1 == asMap.size(), "no single range found encompassing PickleLocation %s", location);
ScenarioDefinition definition = Iterables.getOnlyElement(asMap.values());
Recipe recipe = new Recipe(feature, pickle, location, definition);
recipes.add(recipe);
}
}
}
return recipes;
}
示例5: typeAbstract
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Actual abstract value type that is definitive model for the value type.
* @return abstract value type name forms
*/
@Value.Lazy
public NameForms typeAbstract() {
if (protoclass().kind().isConstructor()) {
return typeValue();
}
List<String> classSegments = Lists.newArrayListWithExpectedSize(2);
Element e = SourceNames.collectClassSegments(protoclass().sourceElement(), classSegments);
verify(e instanceof PackageElement);
String packageOf = ((PackageElement) e).getQualifiedName().toString();
String relative = DOT_JOINER.join(classSegments);
boolean relativeAlreadyQualified = false;
if (!implementationPackage().equals(packageOf)) {
relative = DOT_JOINER.join(packageOf, relative);
relativeAlreadyQualified = true;
}
return ImmutableConstitution.NameForms.builder()
.simple(names().typeAbstract)
.relativeRaw(relative)
.packageOf(packageOf)
.genericArgs(generics().args())
.relativeAlreadyQualified(relativeAlreadyQualified)
.visibility(protoclass().visibility())
.build();
}
示例6: filter
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Filters the elements from the array given as the argument. Always returns with a new array instance containing
* all those elements from the original list whose class is assignable form the {@code predicate} class argument.
*
* @param array
* the input array to filter.
* @param predicate
* the predicate class to filter.
* @return a new type safe filtered array instance.
*/
public static <F, T extends F> T[] filter(final F[] array, final Class<T> predicate) {
checkNotNull(array, "array");
checkNotNull(predicate, "clazz");
final int size = array.length;
final List<T> result = Lists.newArrayListWithExpectedSize(size);
for (int i = 0; i < size; i++) {
final F actual = array[i];
if (null != actual && predicate.isAssignableFrom(actual.getClass())) {
result.add(predicate.cast(actual));
}
}
return Iterables.toArray(result, predicate);
}
示例7: sendAsChunked
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private CompletableFuture<SmtpClientResponse> sendAsChunked(String from, Collection<String> recipients, MessageContent content, Optional<SendInterceptor> sequenceInterceptor) {
if (ehloResponse.isSupported(Extension.PIPELINING)) {
List<Object> objects = Lists.newArrayListWithExpectedSize(3 + recipients.size());
objects.add(mailCommand(from, recipients));
objects.addAll(rpctCommands(recipients));
Iterator<ByteBuf> chunkIterator = content.getContentChunkIterator(channel.alloc());
ByteBuf firstChunk = chunkIterator.next();
if (firstChunk == null) {
throw new IllegalArgumentException("The MessageContent was empty; size is " +
(content.size().isPresent() ? Integer.toString(content.size().getAsInt()) : "not present"));
}
objects.add(getBdatRequestWithData(firstChunk, !chunkIterator.hasNext()));
return beginSequence(sequenceInterceptor, objects.size(), objects.toArray())
.thenSendInTurn(getBdatIterator(chunkIterator))
.toResponses();
} else {
SendSequence sequence = beginSequence(sequenceInterceptor, 1, mailCommand(from, recipients));
for (String recipient : recipients) {
sequence.thenSend(SmtpRequests.rcpt(recipient));
}
return sequence
.thenSendInTurn(getBdatIterator(content.getContentChunkIterator(channel.alloc())))
.toResponses();
}
}
示例8: toOperands
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private List<Object> toOperands(List<String> incoming) {
List<Object> outgoing = Lists.newArrayListWithExpectedSize(incoming.size());
for (String s : incoming) {
outgoing.add(toOperand(s));
}
return outgoing;
}
示例9: save
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public ListenableFuture<List<Void>> save(EntityId entityId, List<TsKvEntry> tsKvEntries, long ttl) {
List<ListenableFuture<Void>> futures = Lists.newArrayListWithExpectedSize(tsKvEntries.size() * INSERTS_PER_ENTRY);
for (TsKvEntry tsKvEntry : tsKvEntries) {
if (tsKvEntry == null) {
throw new IncorrectParameterException("Key value entry can't be null");
}
saveAndRegisterFutures(futures, entityId, tsKvEntry, ttl);
}
return Futures.allAsList(futures);
}
示例10: createPartitionColComparator
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private RexNode createPartitionColComparator(final RexBuilder rexBuilder, List<RexNode> inputs) {
final DrillSqlOperator op = new DrillSqlOperator(WriterPrel.PARTITION_COMPARATOR_FUNC, 1, true);
final List<RexNode> compFuncs = Lists.newArrayListWithExpectedSize(inputs.size());
for (final RexNode input : inputs) {
compFuncs.add(rexBuilder.makeCall(op, ImmutableList.of(input)));
}
return composeDisjunction(rexBuilder, compFuncs);
}
示例11: buttons
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public List<RealmsButton> buttons()
{
List<RealmsButton> list = Lists.<RealmsButton>newArrayListWithExpectedSize(super.buttonList.size());
for (GuiButton guibutton : super.buttonList)
{
list.add(((GuiButtonRealmsProxy)guibutton).getRealmsButton());
}
return list;
}
示例12: ResponseCollector
import com.google.common.collect.Lists; //導入方法依賴的package包/類
ResponseCollector(int expectedResponses, Supplier<String> debugString) {
this.remainingResponses = expectedResponses;
this.debugString = debugString;
responses = Lists.newArrayListWithExpectedSize(expectedResponses);
future = new CompletableFuture<>();
}
示例13: HashAggOperator
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public HashAggOperator(HashAggregate popConfig, OperatorContext context) throws ExecutionSetupException {
this.stats = context.getStats();
this.context = context;
this.outgoing = new VectorContainer(context.getAllocator());
this.popConfig = popConfig;
final int numGrpByExprs = popConfig.getGroupByExprs().size();
comparators = Lists.newArrayListWithExpectedSize(numGrpByExprs);
for (int i=0; i<numGrpByExprs; i++) {
// nulls are equal in group by case
comparators.add(Comparator.IS_NOT_DISTINCT_FROM);
}
}
示例14: buttons
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public List<RealmsButton> buttons()
{
List<RealmsButton> list = Lists.<RealmsButton>newArrayListWithExpectedSize(this.buttonList.size());
for (GuiButton guibutton : this.buttonList)
{
list.add(((GuiButtonRealmsProxy)guibutton).getRealmsButton());
}
return list;
}
示例15: func_154320_j
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public List<RealmsButton> func_154320_j()
{
List<RealmsButton> list = Lists.<RealmsButton>newArrayListWithExpectedSize(super.buttonList.size());
for (GuiButton guibutton : super.buttonList)
{
list.add(((GuiButtonRealmsProxy)guibutton).getRealmsButton());
}
return list;
}