List of usage examples for com.google.common.collect Lists newArrayListWithCapacity
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize)
From source file:org.terasology.entitySystem.metadata.core.FloatTypeHandler.java
public List<Float> deserializeList(EntityData.Value value) { if (value.getFloatCount() > 0) { return Lists.newArrayList(value.getFloatList()); } else if (value.getDoubleCount() > 0) { List<Float> result = Lists.newArrayListWithCapacity(value.getDoubleCount()); for (int i = 0; i < value.getDoubleCount(); ++i) { result.add((float) value.getDouble(i)); }/*from ww w.j av a 2 s . co m*/ return result; } else if (value.getIntegerCount() > 0) { List<Float> result = Lists.newArrayListWithCapacity(value.getIntegerCount()); for (int i = 0; i < value.getIntegerCount(); ++i) { result.add((float) value.getInteger(i)); } return result; } else if (value.getLongCount() > 0) { List<Float> result = Lists.newArrayListWithCapacity(value.getLongCount()); for (int i = 0; i < value.getLongCount(); ++i) { result.add((float) value.getLong(i)); } return result; } return Lists.newArrayList(); }
From source file:org.terasology.persistence.typeSerialization.typeHandlers.extension.BlockFamilyTypeHandler.java
@Override public List<BlockFamily> deserializeCollection(EntityData.Value value) { List<BlockFamily> result = Lists.newArrayListWithCapacity(value.getStringCount()); for (String item : value.getStringList()) { result.add(blockManager.getBlockFamily(item)); }/*w w w . j a v a 2 s. co m*/ return result; }
From source file:com.google.debugging.sourcemap.SourceMapLineDecoder.java
private static List<Integer> decodeLine(StringParser reader) { List<Integer> result = Lists.newArrayListWithCapacity(512); int lastId = 0; while (reader.hasNext()) { LineEntry entry = decodeLineEntry(reader, lastId); lastId = entry.id;//w w w.j a va 2s . c o m for (int i = 0; i < entry.reps; i++) { result.add(entry.id); } } return result; }
From source file:org.codelibs.elasticsearch.taste.common.RefreshHelper.java
/** * @param refreshRunnable// www. j a v a 2 s .co m * encapsulates the containing object's own refresh logic */ public RefreshHelper(final Callable<?> refreshRunnable) { dependencies = Lists.newArrayListWithCapacity(3); refreshLock = new ReentrantLock(); this.refreshRunnable = refreshRunnable; }
From source file:org.terasology.entitySystem.metadata.core.DoubleTypeHandler.java
public List<Double> deserializeList(EntityData.Value value) { if (value.getDoubleCount() > 0) { return Lists.newArrayList(value.getDoubleList()); } else if (value.getFloatCount() > 0) { List<Double> result = Lists.newArrayListWithCapacity(value.getFloatCount()); for (int i = 0; i < value.getFloatCount(); ++i) { result.add((double) value.getFloat(i)); }/*from ww w . ja v a2 s .c o m*/ return result; } else if (value.getIntegerCount() > 0) { List<Double> result = Lists.newArrayListWithCapacity(value.getIntegerCount()); for (int i = 0; i < value.getIntegerCount(); ++i) { result.add((double) value.getInteger(i)); } return result; } else if (value.getLongCount() > 0) { List<Double> result = Lists.newArrayListWithCapacity(value.getLongCount()); for (int i = 0; i < value.getLongCount(); ++i) { result.add((double) value.getLong(i)); } return result; } return Lists.newArrayList(); }
From source file:org.terasology.persistence.typeSerialization.typeHandlers.core.FloatTypeHandler.java
@Override public List<Float> deserializeCollection(EntityData.Value value) { if (value.getFloatCount() > 0) { return Lists.newArrayList(value.getFloatList()); } else if (value.getDoubleCount() > 0) { List<Float> result = Lists.newArrayListWithCapacity(value.getDoubleCount()); for (int i = 0; i < value.getDoubleCount(); ++i) { result.add((float) value.getDouble(i)); }//from ww w. ja v a 2 s.co m return result; } else if (value.getIntegerCount() > 0) { List<Float> result = Lists.newArrayListWithCapacity(value.getIntegerCount()); for (int i = 0; i < value.getIntegerCount(); ++i) { result.add((float) value.getInteger(i)); } return result; } else if (value.getLongCount() > 0) { List<Float> result = Lists.newArrayListWithCapacity(value.getLongCount()); for (int i = 0; i < value.getLongCount(); ++i) { result.add((float) value.getLong(i)); } return result; } return Lists.newArrayList(); }
From source file:org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.selectors.SelectorStateResolverResults.java
public SelectorStateResolverResults(int size) { results = Lists.newArrayListWithCapacity(size); }
From source file:com.yahoo.yqlplus.engine.internal.bytecode.types.gambit.ConstructInvocation.java
public static GambitCreator.Invocable boundInvoke(Type targetType, final TypeWidget owner, final List<BytecodeExpression> args) { List<TypeWidget> types = Lists.newArrayListWithCapacity(args.size()); for (BytecodeExpression expr : args) { types.add(expr.getType());/*from w w w. jav a 2 s .com*/ } return constructor(targetType, owner, types).prefix(args); }
From source file:com.ojuslabs.oct.data.RingSystem.java
/** * @param mol/* w ww . j a v a2 s. co m*/ * The containing molecule of this ring system. */ public RingSystem(Molecule mol) { _mol = mol; _rings = Lists.newArrayListWithCapacity(Constants.LIST_SIZE_S); _atomBitSet = new BitSet(Constants.LIST_SIZE_M); _bondBitSet = new BitSet(Constants.LIST_SIZE_M); }
From source file:org.terasology.persistence.typeSerialization.typeHandlers.core.DoubleTypeHandler.java
@Override public List<Double> deserializeCollection(EntityData.Value value) { if (value.getDoubleCount() > 0) { return Lists.newArrayList(value.getDoubleList()); } else if (value.getFloatCount() > 0) { List<Double> result = Lists.newArrayListWithCapacity(value.getFloatCount()); for (int i = 0; i < value.getFloatCount(); ++i) { result.add((double) value.getFloat(i)); }/*www. jav a 2s .com*/ return result; } else if (value.getIntegerCount() > 0) { List<Double> result = Lists.newArrayListWithCapacity(value.getIntegerCount()); for (int i = 0; i < value.getIntegerCount(); ++i) { result.add((double) value.getInteger(i)); } return result; } else if (value.getLongCount() > 0) { List<Double> result = Lists.newArrayListWithCapacity(value.getLongCount()); for (int i = 0; i < value.getLongCount(); ++i) { result.add((double) value.getLong(i)); } return result; } return Lists.newArrayList(); }