Example usage for com.google.common.collect Lists newArrayListWithExpectedSize

List of usage examples for com.google.common.collect Lists newArrayListWithExpectedSize

Introduction

In this page you can find the example usage for com.google.common.collect Lists newArrayListWithExpectedSize.

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize) 

Source Link

Document

Creates an ArrayList instance to hold estimatedSize elements, plus an unspecified amount of padding; you almost certainly mean to call #newArrayListWithCapacity (see that method for further advice on usage).

Usage

From source file:org.apache.phoenix.schema.SaltingUtil.java

public static List<KeyRange> generateAllSaltingRanges(int bucketNum) {
    List<KeyRange> allRanges = Lists.newArrayListWithExpectedSize(bucketNum);
    for (int i = 0; i < bucketNum; i++) {
        byte[] saltByte = new byte[] { (byte) i };
        allRanges.add(SALTING_COLUMN.getDataType().getKeyRange(saltByte, true, saltByte, true));
    }/*from   w  ww .ja  va 2s  . co  m*/
    return allRanges;
}

From source file:org.summer.dsl.xbase.ui.contentassist.MultiNameDescription.java

public MultiNameDescription(IEObjectDescription delegate) {
    this.otherNames = Lists.newArrayListWithExpectedSize(3);
    this.delegate = delegate;
}

From source file:org.apache.phoenix.mapreduce.util.ColumnInfoToStringEncoderDecoder.java

public static List<ColumnInfo> decode(Configuration configuration) {
    Preconditions.checkNotNull(configuration);
    int numCols = configuration.getInt(CONFIGURATION_COUNT, 0);
    List<ColumnInfo> columnInfos = Lists.newArrayListWithExpectedSize(numCols);
    for (int i = 0; i < numCols; ++i) {
        columnInfos.add(ColumnInfo/*ww  w  .j  a va2s.co m*/
                .fromString(configuration.get(String.format("%s_%d", CONFIGURATION_VALUE_PREFIX, i))));
    }
    return columnInfos;
}

From source file:org.gradle.internal.component.external.model.LazyToRealisedModuleComponentResolveMetadataHelper.java

/**
 * Method to transform lazy variants into realised ones
 *
 * @param mutableMetadata the source metadata
 * @param variantMetadataRules the lazy rules
 * @param variants the variants to transform
 * @return a list of realised variants/*w  ww.  j  a v  a2 s . co  m*/
 */
public static ImmutableList<AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl> realiseVariants(
        ModuleComponentResolveMetadata mutableMetadata, VariantMetadataRules variantMetadataRules,
        ImmutableList<? extends ComponentVariant> variants) {
    List<AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl> realisedVariants = Lists
            .newArrayListWithExpectedSize(variants.size());
    for (ComponentVariant variant : variants) {
        ImmutableAttributes attributes = variantMetadataRules.applyVariantAttributeRules(variant,
                variant.getAttributes());
        CapabilitiesMetadata capabilitiesMetadata = variantMetadataRules.applyCapabilitiesRules(variant,
                variant.getCapabilities());
        List<GradleDependencyMetadata> dependencies = variantMetadataRules.applyDependencyMetadataRules(variant,
                convertDependencies(variant.getDependencies(), variant.getDependencyConstraints()));
        realisedVariants.add(new AbstractRealisedModuleComponentResolveMetadata.ImmutableRealisedVariantImpl(
                mutableMetadata.getId(), variant.getName(), attributes, variant.getDependencies(),
                variant.getDependencyConstraints(), variant.getFiles(),
                ImmutableCapabilities.of(capabilitiesMetadata.getCapabilities()), dependencies));
    }
    return ImmutableList.copyOf(realisedVariants);
}

From source file:com.textocat.textokit.postagger.opennlp.ACPOSContextGenerator.java

@Override
public String[] getContext(int pos, String[] tokens, String[] prevTags, Object[] ac) {
    ArrayList<String> result = Lists.newArrayListWithExpectedSize(ac == null ? 0 : ac.length + 2);
    for (Object acVal : ac) {
        if (acVal instanceof String) {
            result.add((String) acVal);
        }/*from   w w w  . j av  a2 s  . c o  m*/
    }
    ContextGeneratorUtils.addPreviousTags(pos, prevTags, prevTagsInHistory, result);
    return result.toArray(new String[result.size()]);
}

From source file:org.eclipse.emf.ecore.xcore.resource.containers.XcoreContainerManager.java

@Override
protected List<IContainer> getVisibleContainers(List<String> handles,
        IResourceDescriptions resourceDescriptions) {
    if (handles.isEmpty()) {
        return Collections.emptyList();
    } else {//from   w  w w .j  av a2  s  . c  o m
        List<IContainer> result = Lists.newArrayListWithExpectedSize(handles.size());
        for (String handle : handles) {
            IContainer container = createContainer(handle, resourceDescriptions);
            if (!container.isEmpty() || result.isEmpty()) {
                IContainer xCoreContainer = new FilteringContainer(container,
                        new Predicate<IResourceDescription>() {
                            public boolean apply(IResourceDescription input) {
                                return "xcore".equals(input.getURI().fileExtension());
                            }
                        });
                if (!xCoreContainer.isEmpty()) {
                    result.add(xCoreContainer);
                }
                IContainer otherContainer = new FilteringContainer(container,
                        new Predicate<IResourceDescription>() {
                            public boolean apply(IResourceDescription input) {
                                return !"xcore".equals(input.getURI().fileExtension());
                            }
                        });
                if (!otherContainer.isEmpty() || result.isEmpty()) {
                    result.add(otherContainer);
                }
            }
        }
        return result;
    }
}

From source file:ru.codeinside.gses.webui.executor.ProcessTaskQuery.java

@Override
public List<Item> loadItems(int startIndex, int count) {
    Map<String, TaskDefinition> tasks = Flash.flash().getExecutorService()
            .selectTasksByProcedureId(procedureId);
    final List<Item> items = Lists.newArrayListWithExpectedSize(tasks.size());
    for (String key : tasks.keySet()) {
        String taskDefKey = tasks.get(key).getKey();
        String taskName = tasks.get(key).getNameExpression().getExpressionText();
        final PropertysetItem item = new PropertysetItem();
        item.addItemProperty("name", new ObjectProperty<String>(taskName));
        item.addItemProperty("taskDefKey", new ObjectProperty<String>(taskDefKey));
        items.add(item);//from www  . java 2s.  co m

    }
    return items;
}

From source file:org.apache.druid.server.metrics.DruidSysMonitor.java

@Inject
public DruidSysMonitor(SegmentLoaderConfig config) {
    final List<StorageLocationConfig> locs = config.getLocations();
    List<String> dirs = Lists.newArrayListWithExpectedSize(locs.size());
    for (StorageLocationConfig loc : locs) {
        dirs.add(loc.getPath().toString());
    }/*from  w  ww . j a  v  a  2  s.c  om*/

    addDirectoriesToMonitor(dirs.toArray(new String[0]));
}

From source file:com.yahoo.yqlplus.engine.internal.bytecode.types.gambit.ExactInvocation.java

private static List<TypeWidget> prefixTypes(TypeWidget owner, List<TypeWidget> argsWidgets) {
    List<TypeWidget> fullArgsWidgets = Lists.newArrayListWithExpectedSize(argsWidgets.size() + 1);
    fullArgsWidgets.add(owner);/*  w  w  w .j  a v a2 s.c  om*/
    fullArgsWidgets.addAll(argsWidgets);
    argsWidgets = fullArgsWidgets;
    return argsWidgets;
}

From source file:ru.runa.wfe.extension.orgfunction.ExecutorByNameFunction.java

@Override
public List<? extends Executor> getExecutors(Object... parameters) throws OrgFunctionException {
    List<Executor> result = Lists.newArrayListWithExpectedSize(parameters.length);
    for (Object parameter : parameters) {
        Executor executor = TypeConversionUtil.convertToExecutor(parameter, executorDao);
        if (executor != null) {
            result.add(executor);//  w w w . j  av  a 2  s.c om
        }
    }
    return result;
}