Example usage for com.google.common.collect Sets newHashSetWithExpectedSize

List of usage examples for com.google.common.collect Sets newHashSetWithExpectedSize

Introduction

In this page you can find the example usage for com.google.common.collect Sets newHashSetWithExpectedSize.

Prototype

public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) 

Source Link

Document

Creates a HashSet instance, with a high enough initial table size that it should hold expectedSize elements without resizing.

Usage

From source file:org.onosproject.sdnip.HostToInterfaceAdaptor.java

@Override
public Set<Interface> getInterfaces() {
    Set<PortAddresses> addresses = hostService.getAddressBindings();
    Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size());
    for (PortAddresses a : addresses) {
        interfaces.add(new Interface(a));
    }//from w  ww .  j  av  a 2 s.c o  m
    return interfaces;
}

From source file:org.onosproject.routing.config.impl.HostToInterfaceAdaptor.java

public Set<Interface> getInterfaces() {
    Set<PortAddresses> addresses = hostService.getAddressBindings();
    Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size());
    for (PortAddresses a : addresses) {
        interfaces.add(new Interface(a));
    }//from   w ww.  j  a va  2  s .c o  m
    return interfaces;
}

From source file:org.gradoop.flink.model.impl.tuples.GraphTransaction.java

/**
 * Returns the Flink type information of a graph transaction.
 *
 * @param config Gradoop configuration//from   w w  w.j a v  a 2  s . c o m
 * @return type information
 */
public static TypeInformation<GraphTransaction> getTypeInformation(GradoopFlinkConfig config) {

    Set<Vertex> vertices = Sets.newHashSetWithExpectedSize(1);
    vertices.add(config.getVertexFactory().createVertex());

    Set<Edge> 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:com.opengamma.engine.test.CalculationNodeUtils.java

public static Set<ValueSpecification> getMockFunctionInputs(final MockFunction function) {
    final Set<ValueRequirement> requirements = function.getRequirements();
    final Set<ValueSpecification> inputs = Sets.newHashSetWithExpectedSize(requirements.size());
    for (final ValueRequirement requirement : requirements) {
        inputs.add(new ValueSpecification(requirement.getValueName(),
                requirement.getTargetReference().getSpecification(),
                requirement.getConstraints().copy().with(ValuePropertyNames.FUNCTION, "mock").get()));
    }/*from www. ja v  a 2  s .  c o m*/
    return inputs;
}

From source file:cosmos.impl.DedupingPredicate.java

public DedupingPredicate() {
    uids = Sets.newHashSetWithExpectedSize(64);
    holder = new Text();
}

From source file:org.gradoop.flink.model.impl.operators.matching.common.query.DFSTraverser.java

@Override
public TraversalCode traverse(long rootVertex) {
    Set<Long> vertexVisited = Sets.newHashSetWithExpectedSize(queryHandler.getVertexCount());
    Set<Long> edgeVisited = Sets.newHashSetWithExpectedSize(queryHandler.getEdgeCount());
    TraversalCode traversalCode = new TraversalCode();

    long current = rootVertex;

    vertexVisited.add(current);//from w  w w.  j  a v a  2  s.com
    Deque<Edge> edgeStack = new ArrayDeque<>();
    edgeStack.addAll(queryHandler.getEdgesByVertexId(current));

    while (!edgeStack.isEmpty()) {
        Edge edge = edgeStack.removeLast();
        long via = edge.getId();

        if (!edgeVisited.contains(via)) {
            long source = edge.getSourceVertexId();
            long target = edge.getTargetVertexId();

            // backtrack?
            if (current != source && current != target) {
                current = vertexVisited.contains(source) ? source : target;
            }

            // do step
            boolean isOutgoing = current == source;
            long from = isOutgoing ? source : target;
            long to = isOutgoing ? target : source;

            traversalCode.add(new Step(from, via, to, isOutgoing));

            // go deeper
            boolean visitedFrom = vertexVisited.contains(from);
            boolean visitedTo = vertexVisited.contains(to);

            if (!visitedFrom || !visitedTo) {
                current = visitedFrom ? to : from;
                edgeStack.addAll(queryHandler.getEdgesByVertexId(current));
            }

            vertexVisited.add(current);
            edgeVisited.add(via);
        }
    }

    return traversalCode;
}

From source file:fr.inria.maestro.lga.clustering.impl.ClusteringImpl.java

/**
 * Creates classification./*from w ww  . ja  v  a  2  s .  co m*/
 * @param name - the name of classification.
 * @param clusters - the list of classes.
 */
public ClusteringImpl(final String name, final ImmutableList<ICluster> clusters) {
    this.name = name;
    this.clusters = clusters;

    final Set<String> clusterNames = Sets.newHashSetWithExpectedSize(clusters.size());
    for (final ICluster cluster : clusters) {
        clusterNames.add(cluster.getName());
    }
}

From source file:com.android.tools.idea.uibuilder.property.NlPropertiesSorter.java

@NotNull
public static Set<String> getModifiedAttributes(@NotNull List<NlComponent> components) {
    List<AttributeSnapshot> attrs = components.get(0).getAttributes();
    Set<String> modifiedAttrs = Sets.newHashSetWithExpectedSize(attrs.size());
    for (NlComponent component : components) {
        attrs = component.getAttributes();
        for (AttributeSnapshot snapshot : attrs) {
            modifiedAttrs.add(snapshot.name);
        }//from  w w  w. j a  v a2 s  .  c  om
    }
    return modifiedAttrs;
}

From source file:org.gradoop.flink.model.impl.functions.epgm.TransactionFromSets.java

@Override
public GraphTransaction join(GraphHead graphHead, Tuple3<GradoopId, Set<Vertex>, Set<Edge>> sets)
        throws Exception {

    Set<Vertex> vertices;/*from w w  w  . j  a  va 2  s.c  om*/
    Set<Edge> edges;

    if (sets.f0 == null) {
        vertices = Sets.newHashSetWithExpectedSize(0);
        edges = Sets.newHashSetWithExpectedSize(0);
    } else {
        vertices = sets.f1;
        edges = sets.f2;
    }

    return new GraphTransaction(graphHead, vertices, edges);
}

From source file:com.android.tools.idea.run.DeviceStateAtLaunch.java

/** Filters the given set of devices by only selecting those devices that were actually used in this launch. */
public Collection<IDevice> filterByUsed(@NotNull Collection<IDevice> devices) {
    Set<IDevice> used = Sets.newHashSetWithExpectedSize(myDevicesUsedInLaunch.size());

    for (IDevice d : devices) {
        if (myDevicesUsedInLaunch.contains(d.getSerialNumber())) {
            used.add(d);//from   ww  w.ja va 2 s . c  o m
        }
    }

    return used;
}