当前位置: 首页>>代码示例>>Java>>正文


Java Lists.newArrayListWithExpectedSize方法代码示例

本文整理汇总了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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:DatabaseEditDialog.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:SpecialAdminWrapper.java

示例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);
        }
      });
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:23,代码来源:CacheBuilderFactory.java

示例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;
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:25,代码来源:DefaultMixology.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:Constitution.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:Arrays2.java

示例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();
  }
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:33,代码来源:SmtpSession.java

示例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;
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:8,代码来源:MongoWhereClauseListener.java

示例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);
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:12,代码来源:BaseTimeseriesService.java

示例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);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:CreateTableHandler.java

示例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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:GuiScreenRealmsProxy.java

示例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<>();
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:8,代码来源:ResponseCollector.java

示例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);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:HashAggOperator.java

示例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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:GuiScreenRealmsProxy.java

示例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;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:12,代码来源:GuiScreenRealmsProxy.java


注:本文中的com.google.common.collect.Lists.newArrayListWithExpectedSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。