List of usage examples for com.google.common.collect Sets newHashSetWithExpectedSize
public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize)
From source file:com.doctusoft.bean.binding.observable.ObservableSet.java
public ObservableSet(int size) { delegate = Sets.newHashSetWithExpectedSize(size); }
From source file:com.android.tools.idea.run.DeviceStateAtLaunch.java
private static Set<String> serialize(Collection<IDevice> usedDevices) { Set<String> s = Sets.newHashSetWithExpectedSize(usedDevices.size()); for (IDevice d : usedDevices) { s.add(d.getSerialNumber());/*from w w w . j a v a2s .c om*/ } return s; }
From source file:org.gradoop.flink.model.impl.functions.epgm.GraphVerticesEdges.java
@Override public Tuple3<GradoopId, Set<Vertex>, Set<Edge>> join(Tuple2<GradoopId, Set<Vertex>> vertexPair, Tuple2<GradoopId, Set<Edge>> edgePair) throws Exception { GradoopId graphId;/* w w w . java 2 s . c o m*/ Set<Vertex> vertices; Set<Edge> edges; if (vertexPair == null) { graphId = edgePair.f0; vertices = Sets.newHashSetWithExpectedSize(0); edges = edgePair.f1; } else { graphId = vertexPair.f0; vertices = vertexPair.f1; edges = edgePair == null ? getEmptyEdgeSet() : edgePair.f1; } return new Tuple3<>(graphId, vertices, edges); }
From source file:com.android.ddmuilib.heap.NativeHeapDiffSnapshot.java
private static List<NativeAllocationInfo> getNewAllocations(NativeHeapSnapshot newSnapshot, NativeHeapSnapshot oldSnapshot) { Set<NativeAllocationInfo> allocations = new HashSet<NativeAllocationInfo>(newSnapshot.getAllocations()); // compute new allocations allocations.removeAll(oldSnapshot.getAllocations()); // Account for allocations with the same stack trace that were // present in the older set of allocations. // e.g. A particular stack trace might have had 3 allocations in snapshot 1, // and 2 more in snapshot 2. We only want to show the new allocations (just the 2 from // snapshot 2). However, the way the allocations are stored, in snapshot 2, we'll see // 5 allocations at the stack trace. We need to subtract out the 3 from the first allocation Set<NativeAllocationInfo> onlyInPrevious = new HashSet<NativeAllocationInfo>(oldSnapshot.getAllocations()); Set<NativeAllocationInfo> newAllocations = Sets.newHashSetWithExpectedSize(allocations.size()); onlyInPrevious.removeAll(newSnapshot.getAllocations()); for (NativeAllocationInfo current : allocations) { NativeAllocationInfo old = getOldAllocationWithSameStack(current, onlyInPrevious); if (old == null) { newAllocations.add(current); } else if (current.getAllocationCount() > old.getAllocationCount()) { newAllocations.add(new NativeDiffAllocationInfo(current, old)); }//from www . j a v a 2 s .c o m } return new ArrayList<NativeAllocationInfo>(newAllocations); }
From source file:org.openqa.selenium.android.app.WebViewManager.java
public Set<String> getAllHandles() { Set<String> handles = Sets.newHashSetWithExpectedSize(views.size()); for (WebDriverWebView view : views) { handles.add(view.getWindowHandle()); }// w w w .jav a2 s .c om return handles; }
From source file:org.gradoop.model.impl.tuples.GraphTransaction.java
/** * Returns the Flink type information of a graph transaction. * * @param config Gradoop configuration/* w w w. j a va 2 s .co m*/ * @param <G> EPGM graph head type * @param <V> EPGM vertex type * @param <E> EPGM edge type * @return type information */ public static <G extends EPGMGraphHead, V extends EPGMVertex, E extends EPGMEdge> TypeInformation<GraphTransaction<G, V, E>> getTypeInformation( GradoopConfig<G, V, E> config) { Set<V> vertices = Sets.newHashSetWithExpectedSize(1); vertices.add(config.getVertexFactory().createVertex()); Set<E> edges = Sets.newHashSetWithExpectedSize(1); edges.add(config.getEdgeFactory().createEdge(GradoopId.get(), GradoopId.get())); return TypeExtractor.getForObject( new GraphTransaction<>(config.getGraphHeadFactory().createGraphHead(), vertices, edges)); }
From source file:abstractions.position.PositionManager.java
public Set<PositionInterface> newPositionSet() { final Set<PositionInterface> positions = Sets .newHashSetWithExpectedSize(this.directionManager.getDimensionManager().capacity() + 1); positions.add(this.newPosition(0, 0)); final int maxRowIndex = this.directionManager.getDimensionManager().upperBoundForRows(); final int maxColumnIndex = this.directionManager.getDimensionManager().upperBoundForColumns(); for (int rowIndex = this.directionManager.getDimensionManager() .lowerBoundForRows(); rowIndex <= maxRowIndex; ++rowIndex) { for (int columnIndex = this.directionManager.getDimensionManager() .lowerBoundForColumns(); columnIndex <= maxColumnIndex; ++columnIndex) { positions.add(this.newPosition(rowIndex, columnIndex)); }//from w ww . ja va 2s.co m } return Collections.unmodifiableSet(positions); }
From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraJMXCompactionManager.java
private CassandraJMXCompactionManager() { this.compactionClients = Sets.newHashSetWithExpectedSize(0); }
From source file:com.palantir.atlasdb.table.generation.ColumnValues.java
public static <T extends Persistable, V extends Persistable> Set<Cell> toCells(Multimap<T, V> map) { Set<Cell> ret = Sets.newHashSetWithExpectedSize(map.size()); for (Entry<T, Collection<V>> e : map.asMap().entrySet()) { byte[] rowName = e.getKey().persistToBytes(); for (Persistable val : e.getValue()) { ret.add(Cell.create(rowName, val.persistToBytes())); }/* w w w .ja v a 2 s . c o m*/ } return ret; }
From source file:org.eclipse.xtext.xbase.typesystem.util.Maps2.java
/** * Puts a value into a map that supports lists as values. * The list is created on-demand./*from w ww . j a va 2s. c o m*/ */ public static <K, V> void putIntoSetMap(K key, V value, Map<? super K, Set<V>> map) { Set<V> list = map.get(key); if (list == null) { list = Sets.newHashSetWithExpectedSize(2); map.put(key, list); } list.add(value); }