Example usage for com.google.common.collect LinkedHashMultimap create

List of usage examples for com.google.common.collect LinkedHashMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect LinkedHashMultimap create.

Prototype

public static <K, V> LinkedHashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) 

Source Link

Document

Constructs an empty LinkedHashMultimap with enough capacity to hold the specified numbers of keys and values without rehashing.

Usage

From source file:org.eclipse.xtext.scoping.impl.MultimapBasedScope.java

public static IScope createScope(IScope parent, Iterable<IEObjectDescription> descriptions,
        boolean ignoreCase) {
    Multimap<QualifiedName, IEObjectDescription> map = null;
    for (IEObjectDescription description : descriptions) {
        if (map == null)
            map = LinkedHashMultimap.create(5, 2);
        if (ignoreCase)
            map.put(description.getName().toLowerCase(), description);
        else/*from w  w w . jav  a2s  .  c  o  m*/
            map.put(description.getName(), description);
    }
    if (map == null || map.isEmpty()) {
        return parent;
    }
    return new MultimapBasedScope(parent, map, ignoreCase);
}

From source file:org.dslforge.xtext.common.scoping.BasicTextMultimapBasedScope.java

public static IScope createScope(IScope parent, Iterable<IEObjectDescription> descriptions, boolean ignoreCase,
        List<URI> uris) {
    availableResourceURs = uris;/* w  w  w  . j  a va 2s . c om*/
    Multimap<QualifiedName, IEObjectDescription> map = null;
    for (IEObjectDescription description : descriptions) {
        if (map == null)
            map = LinkedHashMultimap.create(5, 2);
        if (ignoreCase)
            map.put(description.getName().toLowerCase(), description);
        else
            map.put(description.getName(), description);
    }
    if (map == null || map.isEmpty()) {
        return parent;
    }
    return new BasicTextMultimapBasedScope(parent, map, ignoreCase);
}

From source file:eu.lp0.cursus.xml.scores.results.ScoresXMLSeriesResults.java

public ScoresXMLSeriesResults(Scores scores) {
    super(scores);

    series = AbstractXMLEntity.generateId(scores.getSeries());

    discards = scores.getDiscardCount();

    Multimap<Event, Race> events_ = LinkedHashMultimap.create(scores.getRaces().size(),
            scores.getRaces().size());//from ww  w  .  ja v a 2 s.  com
    for (Race race : scores.getRaces()) {
        events_.put(race.getEvent(), race);
    }

    eventResults = new ArrayList<ScoresXMLSeriesEventResults>(events_.keySet().size());
    for (Entry<Event, Collection<Race>> event : events_.asMap().entrySet()) {
        eventResults.add(new ScoresXMLSeriesEventResults(scores, event.getKey(), event.getValue()));
    }
}

From source file:org.dragoneronca.nlp.wol.domain.RangedSenseScanner.java

public RangedSenseScanner(int maxRetrieved) {
    this.maxRetrieved = maxRetrieved;
    senses = LinkedHashMultimap.create(maxRetrieved, 16);
}

From source file:io.bazel.rules.closure.webfiles.Webset.java

/**
 * Loads graph of web files from proto manifests.
 *
 * @param manifests set of web rule target proto files in reverse topological order
 * @return set of web files and relationships between them, which could be mutated, although
 *     adding a single key will most likely result in a full rehash
 *//*from   w  ww .j a  v  a2s  .  c om*/
public static Webset load(Map<Path, WebfileManifestInfo> manifests, WebpathInterner interner) {
    int webfileCapacity = 0;
    int unlinkCapacity = 16; // LinkedHashMultimap#DEFAULT_KEY_CAPACITY
    for (WebfileManifestInfo manifest : manifests.values()) {
        webfileCapacity += manifest.getWebfileCount();
        unlinkCapacity = Math.max(unlinkCapacity, manifest.getUnlinkCount());
    }
    Map<Webpath, Webfile> webfiles = Maps.newLinkedHashMapWithExpectedSize(webfileCapacity);
    Multimap<Webpath, Webpath> links = LinkedHashMultimap.create(webfileCapacity, 4);
    Multimap<Webpath, Webpath> unlinks = LinkedHashMultimap.create(unlinkCapacity, 4);
    for (Map.Entry<Path, WebfileManifestInfo> entry : manifests.entrySet()) {
        Path manifestPath = entry.getKey();
        Path zipPath = WebfilesUtils.getIncrementalZipPath(manifestPath);
        WebfileManifestInfo manifest = entry.getValue();
        String label = manifest.getLabel();
        for (WebfileInfo info : manifest.getWebfileList()) {
            Webpath webpath = interner.get(info.getWebpath());
            webfiles.put(webpath, Webfile.create(webpath, zipPath, label, info));
        }
        for (MultimapInfo mapping : manifest.getLinkList()) {
            Webpath from = interner.get(mapping.getKey());
            for (Webpath to : Iterables.transform(mapping.getValueList(), interner)) {
                // When compiling web_library rules, if the strict dependency checking invariant holds
                // true, we can choose to only load adjacent manifests, rather than transitive ones. The
                // adjacent manifests may contain links to transitive web files which will not be in the
                // webfiles map.
                if (webfiles.containsKey(to)) {
                    links.put(from, to);
                    checkArgument(!unlinks.containsEntry(from, to),
                            "Has a use case for resurrected links been discovered? %s -> %s", from, to);
                }
            }
        }
        for (MultimapInfo mapping : manifest.getUnlinkList()) {
            unlinks.putAll(interner.get(mapping.getKey()),
                    Collections2.transform(mapping.getValueList(), interner));
        }
    }
    for (Map.Entry<Webpath, Webpath> entry : unlinks.entries()) {
        links.remove(entry.getKey(), entry.getValue());
    }
    unlinks.clear();
    return new AutoValue_Webset(webfiles, links, interner);
}

From source file:com.preferanser.shared.domain.Editor.java

public Editor reset() {
    name = null;//from   ww w . j  av a 2  s  .  c o m
    description = null;
    firstTurn = null;
    players = null;
    widow = new Widow();
    handContracts = Maps.newHashMapWithExpectedSize(Hand.PLAYING_HANDS.size());
    centerCardHandMap = Maps.newLinkedHashMap(); // order is important
    handCardMultimap = LinkedHashMultimap.create(TableLocation.values().length, Card.values().length);
    return this;
}

From source file:com.vmware.appfactory.taskqueue.tasks.TaskRecorder.java

TaskRecorder(int expectedSize, int maxFinishedSize, int expectedTasksPerId) {

    mapTaskIdToTask = Maps.newHashMapWithExpectedSize(expectedSize);
    mapTaskHandleToTasks = LinkedHashMultimap.create(expectedSize + maxFinishedSize, expectedTasksPerId);

}

From source file:de.unentscheidbar.validation.swing.trigger.DelayedTrigger.java

DelayedTrigger(@Nonnegative int delay, Trigger<C> other) {

    Objects.requireNonNull(other, "other");
    this.timer = new Timer(delay, this);
    this.timer.setRepeats(false);
    this.timer.setCoalesce(false);
    this.other = other;
    this.pendingEvents = new IdentityHashMap<>(1);
    this.observed = LinkedHashMultimap.create(4, 1);
}

From source file:com.google.javascript.jscomp.NameBasedDefinitionProvider.java

public NameBasedDefinitionProvider(AbstractCompiler compiler, boolean allowComplexFunctionDefs) {
    this.compiler = compiler;
    this.allowComplexFunctionDefs = allowComplexFunctionDefs;
    int numInputs = compiler.getNumberOfInputs();
    // Estimates below were generated by experimentation with large Google projects.
    this.definitionsByName = LinkedHashMultimap.create(numInputs * 15, 1);
    int estimatedDefinitionSites = numInputs * 22;
    this.definitionSitesByDefinitionSiteNode = Maps.newLinkedHashMapWithExpectedSize(estimatedDefinitionSites);
    this.definitionSitesByScopeNode = HashMultimap.create(estimatedDefinitionSites, 1);
    this.definitionNodes = Sets.newHashSetWithExpectedSize(estimatedDefinitionSites);
}

From source file:de.unentscheidbar.validation.ValidationResult.java

private ValidationResult() {

    this.mapLock = new ReentrantReadWriteLock();
    this.messageMap = LinkedHashMultimap.create(Severity.values().length, 0);
}