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

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

Introduction

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

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize) 

Source Link

Document

Creates an ArrayList instance backed by an array with the specified initial size; simply delegates to ArrayList#ArrayList(int) .

Usage

From source file:org.summer.dsl.xbase.typesystem.legacy.LegacyTypeConformanceComputer.java

@Override
public JvmTypeReference getCommonSuperType(List<JvmTypeReference> types) {
    Resource resource = null;/*www  . j a  va 2 s.  co m*/
    for (JvmTypeReference type : types) {
        resource = getResource(type);
        if (resource != null) {
            break;
        }
    }
    if (resource == null)
        return super.getCommonSuperType(types);
    StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resource);
    OwnedConverter converter = new OwnedConverter(owner);
    List<LightweightTypeReference> lightweightTypes = Lists.newArrayListWithCapacity(types.size());
    for (JvmTypeReference type : types) {
        lightweightTypes.add(converter.toLightweightReference(type));
    }
    LightweightTypeReference result = services.getTypeConformanceComputer().getCommonSuperType(lightweightTypes,
            owner);
    if (result == null) {
        return null;
    }
    return result.toTypeReference();
}

From source file:com.ojuslabs.oct.data.Reaction.java

public Reaction(int n) {
    _reactionNumber = n;/*from   ww  w . java  2 s . c  o m*/

    _pSubstructures = Lists.newArrayListWithCapacity(LIST_SIZE_S);
    _prodCriteria = Lists.newArrayListWithCapacity(LIST_SIZE_S);
    _reacCriteria = Lists.newArrayListWithCapacity(LIST_SIZE_S);
    _reagents = Lists.newArrayListWithCapacity(LIST_SIZE_S);

    _references = Lists.newArrayListWithCapacity(LIST_SIZE_S);
}

From source file:com.android.sdklib.build.RenderScriptChecker.java

public void loadDependencies() throws IOException {
    // get the dependency data from all files under bin/rsDeps/
    File renderscriptDeps = new File(mBinFolder, RenderScriptProcessor.RS_DEPS);

    File[] depsFiles = null;/*from  www  . j  ava  2 s .  c  om*/

    if (renderscriptDeps.isDirectory()) {
        depsFiles = renderscriptDeps.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File file, String s) {
                return s.endsWith(DOT_DEP);
            }
        });
    }

    int count = depsFiles != null ? depsFiles.length : 0;
    mDependencyFiles = Lists.newArrayListWithCapacity(0);
    mOldOutputs = Sets.newHashSet();
    mOldInputs = Sets.newHashSet();
    if (count > 0) {
        for (File file : depsFiles) {
            DependencyFile depFile = new DependencyFile(file, mSourceFolders);
            depFile.parse();
            mDependencyFiles.add(depFile);
            // record old inputs
            mOldOutputs.addAll(depFile.getOutputFiles());
            // record old inputs
            mOldInputs.addAll(depFile.getInputFiles());
        }
    }
}

From source file:org.apache.tez.dag.app.dag.impl.BroadcastEdgeManager.java

@Override
public void routeInputSourceTaskFailedEventToDestination(int sourceTaskIndex, int numDestinationTasks,
        Map<Integer, List<Integer>> inputIndicesToTaskIndices) {
    List<Integer> taskIndices = Lists.newArrayListWithCapacity(numDestinationTasks);
    addAllDestinationTaskIndices(numDestinationTasks, taskIndices);
    inputIndicesToTaskIndices.put(new Integer(sourceTaskIndex), taskIndices);
}

From source file:org.apache.flink.streaming.api.windowing.assigners.SlidingProcessingTimeWindows.java

private SlidingProcessingTimeWindows(long size, long slide) {
    this.size = size;
    this.slide = slide;
    this.result = Lists.newArrayListWithCapacity((int) (size / slide));
}

From source file:at.molindo.esi4j.action.impl.DefaultSearchResponseWrapper.java

@Override
public <T> List<T> getObjects(Class<T> type) {
    List<SearchHitWrapper> hits = getSearchHits();
    List<T> objects = Lists.newArrayListWithCapacity(hits.size());

    for (SearchHitWrapper hit : hits) {
        objects.add(hit.getObject(type));
    }/*from  w  ww.jav  a2 s. c  om*/

    return objects;
}

From source file:org.grouplens.lenskit.util.parallel.ParallelTaskGraphExecutor.java

@Override
public <T extends Callable<?>, E> void execute(DAGNode<T, E> graph)
        throws ExecutionException, InterruptedException {
    logger.info("{}: executing {} tasks on {} threads", name, graph.getReachableNodes().size(), threadCount);
    TaskGraphManager<T, E> manager = new TaskGraphManager<T, E>(name, graph);
    List<Thread> threads = Lists.newArrayListWithCapacity(threadCount);
    for (int i = 1; i <= threadCount; i++) {
        Thread thread = new TaskGraphThread<T, E>(manager, String.format("%s-%d", name, i));
        threads.add(thread);// www . j a v  a 2 s.c  o  m
        manager.addThread(thread);
        thread.start();
    }
    try {
        manager.waitForFinished();
    } catch (Exception ex) {
        for (Thread th : threads) {
            th.interrupt();
        }
        Throwables.propagateIfPossible(ex, ExecutionException.class, InterruptedException.class);
        throw new RuntimeException(ex);
    }
}

From source file:com.shopwiki.roger.rpc.BasicWorkerFactory.java

@Override
public List<RpcWorker> createWorkers(Connection conn, String queuePrefix) throws IOException {

    List<Channel> channels = new ArrayList<Channel>();

    for (int i = 0; i < numThreads; i++) {
        Channel channel = conn.createChannel();
        channel.basicQos(1);/*  w  ww.  j  av a  2 s.c om*/
        channels.add(channel);
    }

    List<RpcWorker> workers = Lists.newArrayListWithCapacity(nameToHandler.size());

    for (String procedureName : nameToHandler.keySet()) {
        RequestHandler<?, ?> handler = nameToHandler.get(procedureName);
        RpcWorker worker = new RpcWorker(handler, channels, queuePrefix, procedureName);
        workers.add(worker);
    }

    return workers;
}

From source file:org.terasology.persistence.typeSerialization.typeHandlers.extension.AssetTypeHandler.java

@Override
public List<T> deserializeCollection(EntityData.Value value) {
    List<T> result = Lists.newArrayListWithCapacity(value.getStringCount());
    for (String item : value.getStringList()) {
        Asset asset = Assets.resolve(type, item);
        if (asset != null && assetClass.isAssignableFrom(asset.getClass())) {
            result.add(assetClass.cast(asset));
        }//from  ww  w. jav  a 2s. com
    }
    return result;
}

From source file:com.doctusoft.bean.binding.observable.ObservableList.java

public ObservableList(int initialCapacity) {
    delegate = Lists.newArrayListWithCapacity(initialCapacity);
}