List of usage examples for com.google.common.collect HashBiMap create
public static <K, V> HashBiMap<K, V> create(Map<? extends K, ? extends V> map)
From source file:com.google.idea.blaze.java.libraries.JarCache.java
public void onSync(BlazeContext context, BlazeProjectData projectData, BlazeSyncParams.SyncMode syncMode) { Collection<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectData); boolean fullRefresh = syncMode == SyncMode.FULL; boolean removeMissingFiles = syncMode == SyncMode.INCREMENTAL; boolean enabled = updateEnabled(); if (!enabled || fullRefresh) { clearCache();// w w w .j ava2 s.c o m } if (!enabled) { return; } boolean attachAllSourceJars = BlazeJavaUserSettings.getInstance().getAttachSourcesByDefault(); SourceJarManager sourceJarManager = SourceJarManager.getInstance(project); List<BlazeJarLibrary> jarLibraries = libraries.stream() .filter(library -> library instanceof BlazeJarLibrary).map(library -> (BlazeJarLibrary) library) .collect(Collectors.toList()); ArtifactLocationDecoder artifactLocationDecoder = projectData.artifactLocationDecoder; BiMap<File, String> sourceFileToCacheKey = HashBiMap.create(jarLibraries.size()); for (BlazeJarLibrary library : jarLibraries) { File jarFile = artifactLocationDecoder.decode(library.libraryArtifact.jarForIntellijLibrary()); sourceFileToCacheKey.put(jarFile, cacheKeyForJar(jarFile)); boolean attachSourceJar = attachAllSourceJars || sourceJarManager.hasSourceJarAttached(library.key); if (attachSourceJar && library.libraryArtifact.sourceJar != null) { File srcJarFile = artifactLocationDecoder.decode(library.libraryArtifact.sourceJar); sourceFileToCacheKey.put(srcJarFile, cacheKeyForSourceJar(srcJarFile)); } } this.sourceFileToCacheKey = sourceFileToCacheKey; refresh(context, removeMissingFiles); }
From source file:test.jamocha.util.builder.rule.ECSetRuleBuilder.java
public ConstructCache.Defrule.ECSetRule build() { if (1 != this.stack.size()) { throw new IllegalStateException("Rule can only be constructed if all existential scopes are closed!"); }//from w ww . j a v a 2 s. co m final AbstractConditionProxy conditionProxy = this.stack.pop(); final Set<ECFilterSet> condition = conditionProxy.condition; final Set<SingleFactVariable> factVariableSet = conditionProxy.factVariableSet; final Set<RuleCondition.EquivalenceClass> equivalenceClasses = conditionProxy.equivalenceClasses; equivalenceClasses.addAll(this.constantToEquivalenceClass.values()); final Set<RuleCondition.EquivalenceClass> usedECs = ECCollector.collect(condition); if (usedECs.contains(this.initialFactVariable.getEqual())) { factVariableSet.add(this.initialFactVariable); equivalenceClasses.add(this.initialFactVariable.getEqual()); } final ConstructCache.Defrule defrule = new ConstructCache.Defrule(this.ruleName, "", 0, null, new FunctionWithArguments[] {}); final ConstructCache.Defrule.ECSetRule ecSetRule = defrule.newECSetRule(condition, factVariableSet, equivalenceClasses, HashBiMap.create(0), 0); return ecSetRule; }
From source file:org.opencb.opencga.storage.core.metadata.StudyConfiguration.java
public StudyConfiguration(int studyId, String studyName, Map<String, Integer> fileIds, Map<String, Integer> sampleIds, Map<String, Integer> cohortIds, Map<Integer, Set<Integer>> cohorts) { this.studyId = studyId; this.studyName = studyName; this.fileIds = HashBiMap.create(fileIds == null ? Collections.emptyMap() : fileIds); this.sampleIds = HashBiMap.create(sampleIds == null ? Collections.emptyMap() : sampleIds); this.cohortIds = HashBiMap.create(cohortIds == null ? Collections.emptyMap() : cohortIds); this.cohorts = cohorts; this.indexedFiles = new LinkedHashSet<>(); this.headers = HashBiMap.create(); this.samplesInFiles = HashBiMap.create(); this.calculatedStats = new LinkedHashSet<>(); this.invalidStats = new LinkedHashSet<>(); this.aggregation = VariantSource.Aggregation.NONE; this.attributes = new ObjectMap(); }
From source file:org.apache.s4.comm.tcp.TCPEmitter.java
/** * /*from w w w .j a va2 s . com*/ * @param topology * the target cluster configuration * @param timeout * netty timeout * @param maxPendingWrites * maximum number of events not yet flushed to the TCP buffer * @throws InterruptedException * in case of an interruption */ @Inject public TCPEmitter(Cluster topology, @Named("s4.comm.timeout") int timeout, @Named("s4.emitter.maxPendingWrites") int maxPendingWrites) throws InterruptedException { // logger.debug("Create TCP Emitter | Cluster: " + topology.getPhysicalCluster().toString()); this.nettyTimeout = timeout; this.topology = topology; this.maxPendingWrites = maxPendingWrites; this.lock = new ReentrantLock(); // Initialize data structures int clusterSize = this.topology.getPhysicalCluster().getNodes().size(); partitionChannelMap = HashBiMap.create(clusterSize); partitionNodeMap = HashBiMap.create(clusterSize); // Initialize netty related structures ChannelFactory factory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); bootstrap = new ClientBootstrap(factory); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { ChannelPipeline p = Channels.pipeline(); p.addLast("1", new LengthFieldPrepender(4)); p.addLast("2", new ExceptionHandler()); return p; } }); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("keepAlive", true); bootstrap.setOption("reuseAddress", true); bootstrap.setOption("connectTimeoutMillis", this.nettyTimeout); }
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.check.code.model.checker.DefaultCodeChecker.java
private DefaultCodeChecker(final BotConfiguration botSettings, final LanguageConfiguration languageSettings, final Map<URI, String> namespacesToPrefixes) { Preconditions.checkNotNull(botSettings); Preconditions.checkNotNull(languageSettings); Preconditions.checkNotNull(namespacesToPrefixes.containsKey(URI.create(AIML.NAMESPACE_URI.getValue()))); Preconditions// w w w. j a va 2s. c o m .checkNotNull(namespacesToPrefixes.containsKey(URI.create(XML.SCHEMA_NAMESPACE_URI.getValue()))); Preconditions.checkNotNull(namespacesToPrefixes); HashBiMap.create(namespacesToPrefixes); this.botSettings = botSettings; this.languageSettings = languageSettings; this.namespacesToPrefixes = namespacesToPrefixes; }
From source file:org.openscience.cdk.graph.InitialCycles.java
/** * Internal constructor - takes a graph and a flag that the graph is a * biconnected component. This allows a minor optimisation to trigger. * * @param graph input graph//from w ww. j av a2s. c o m * @param biconnected the graph is known to be biconnected * @throws NullPointerException the graph was null */ private InitialCycles(final int[][] graph, final int limit, boolean biconnected) { this.graph = checkNotNull(graph, "no graph provided"); // ordering ensures the number of initial cycles is polynomial this.biconnected = biconnected; this.limit = limit; this.ordering = ordering(graph); // index the edges to allow us to jump between edge and path representation // - edge representation: binary vector indicates whether an edge // is present or // - path representation: sequential list vertices forming the cycle edges = HashBiMap.create(graph.length); int n = graph.length; for (int v = 0; v < n; v++) { for (int w : graph[v]) { if (w > v) { Edge edge = new Edge(v, w); edges.put(edge, edges.size()); } } } // compute the initial set of cycles compute(); }
From source file:agents.firm.Firm.java
/** * the usual constructor, checks for gui to build panel * @param model//from w ww . j av a 2s. c om */ public Firm(MacroII model) { super(model); salesDepartments = new HashMap<>(); purchaseDepartments = new HashMap<>(); humanResources = HashBiMap.create(1); //factory method for this numberOfPlantsListeners = new HashSet<>(); //prepare for listeners profitReport = new DailyProfitReport(this); //create the timeline manager if (MacroII.hasGUI()) { //build the inspector buildInspector(); } }
From source file:mvm.rya.indexing.external.ExternalProcessor.java
private void setSupportedVarOrderMap(ExternalTupleSet index) { Map<String, Set<String>> supportedVarOrders = Maps.newHashMap(); BiMap<String, String> biMap = HashBiMap.create(index.getTableVarMap()).inverse(); Map<String, Set<String>> oldSupportedVarOrders = index.getSupportedVariableOrderMap(); Set<String> temp = null; Set<String> keys = oldSupportedVarOrders.keySet(); for (String s : keys) { temp = oldSupportedVarOrders.get(s); Set<String> newSet = Sets.newHashSet(); for (String t : temp) { newSet.add(biMap.get(t));/* www .j av a 2s .co m*/ } String[] tempStrings = s.split("\u0000"); String v = ""; for (String u : tempStrings) { if (v.length() == 0) { v = v + biMap.get(u); } else { v = v + "\u0000" + biMap.get(u); } } supportedVarOrders.put(v, newSet); } index.setSupportedVariableOrderMap(supportedVarOrders); }
From source file:org.jamocha.languages.common.RuleConditionProcessor.java
public static CopyWithMetaInformation copyDeeplyUsingNewECsAndFactVariables( final ConditionalElement<ECLeaf> child, final Collection<EquivalenceClass> equivalenceClasses) { final HashBiMap<EquivalenceClass, EquivalenceClass> oldToNewEC = HashBiMap.create(equivalenceClasses .stream().collect(toMap(java.util.function.Function.identity(), EquivalenceClass::new))); for (final Map.Entry<EquivalenceClass, EquivalenceClass> entry : oldToNewEC.entrySet()) { final EquivalenceClass oldEC = entry.getKey(); final EquivalenceClass newEC = entry.getValue(); oldEC.getEqualParentEquivalenceClasses().stream().map(oldToNewEC::get) .forEach(newEC::addEqualParentEquivalenceClass); }//from w ww. j a va 2 s .c o m // collect all fact variables contained in this child final List<SingleFactVariable> deepFactVariables = DeepFactVariableCollector.collect(child); // copy all fact variables contained in this child while making them point at the // newly created equivalence classes final HashBiMap<SingleFactVariable, SingleFactVariable> oldToNewFV = HashBiMap .create(deepFactVariables.stream().collect(toMap(Function.identity(), (final SingleFactVariable fv) -> new SingleFactVariable(fv, oldToNewEC)))); // replace the old FVs in the new ECs by the new FVs for (final Iterator<EquivalenceClass> ecIter = oldToNewEC.values().iterator(); ecIter.hasNext();) { final EquivalenceClass newEC = ecIter.next(); newEC.getFactVariables().removeIf(negate(deepFactVariables::contains)); newEC.getSlotVariables().removeIf(sv -> !deepFactVariables.contains(sv.getFactVariable())); if (newEC.getElementCount() == 0) { ecIter.remove(); continue; } newEC.getFactVariables().replaceAll(oldToNewFV::get); newEC.getSlotVariables() .replaceAll(sv -> oldToNewFV.get(sv.getFactVariable()).getSlots().get(sv.getSlot())); } final ConditionalElement<ECLeaf> copy = child.accept(new CEECReplacer(oldToNewEC, oldToNewFV)).getResult(); // remove all equivalence classes not occurring in the filters and only consisting of a single constant xor a // single functional expression final Set<EquivalenceClass> usedECs = copy.accept(new DeepECCollector()).getEquivalenceClasses(); oldToNewEC.values().removeIf(ec -> !usedECs.contains(ec) && ec.getElementCount() == 1 && !(ec.getConstantExpressions().isEmpty() && ec.getFunctionalExpressions().isEmpty())); return new CopyWithMetaInformation(copy, oldToNewEC, oldToNewFV); }
From source file:org.mycore.tools.MCRTopologicalSort.java
/** * reads MCRObjectIDs, retrieves parent links from MCRLinkTableManager * and creates the graph//from www .ja v a2s . co m * * uses StAX cursor API (higher performance) */ public void prepareMCRObjects(String[] mcrids) { nodes = HashBiMap.create(mcrids.length); edgeSources.clear(); for (int i = 0; i < mcrids.length; i++) { nodes.forcePut(i, mcrids[i]); } for (int i = 0; i < mcrids.length; i++) { Collection<String> parents = MCRLinkTableManager.instance().getDestinationOf(mcrids[i], "parent"); for (String p : parents) { Integer target = nodes.inverse().get(p); if (target != null) { addEdge(i, target); } } Collection<String> refs = MCRLinkTableManager.instance().getDestinationOf(mcrids[i], "reference"); for (String r : refs) { Integer target = nodes.inverse().get(r); if (target != null) { addEdge(i, target); } } } dirty = false; }