List of usage examples for com.google.common.collect Sets newHashSet
public static <E> HashSet<E> newHashSet()
From source file:org.jetbrains.jet.lang.resolve.scopes.JetScopeSelectorUtil.java
@NotNull public static <D extends DeclarationDescriptor> Collection<D> collect(Collection<JetScope> scopes, ScopeByNameMultiSelector<D> selector, Name name) { Set<D> descriptors = Sets.newHashSet(); for (JetScope scope : scopes) { descriptors.addAll(selector.get(scope, name)); }/* www .ja v a2 s . c o m*/ return descriptors; }
From source file:org.apache.rocketmq.console.model.ConnectionInfo.java
public static HashSet<Connection> buildConnectionInfoHashSet(Collection<Connection> connectionList) { HashSet<Connection> connectionHashSet = Sets.newHashSet(); for (Connection connection : connectionList) { connectionHashSet.add(buildConnectionInfo(connection)); }//w w w . j ava 2s.c om return connectionHashSet; }
From source file:org.apache.kylin.cube.cuboid.algorithm.CuboidStatsUtil.java
/** * For generating mandatory cuboids,//from w ww. ja v a 2s. c om * a cuboid is mandatory if the expectation of rolling up count exceeds a threshold * */ public static Set<Long> generateMandatoryCuboidSet(Map<Long, Long> statistics, Map<Long, Long> hitFrequencyMap, Map<Long, Map<Long, Long>> rollingUpCountSourceMap, final long rollUpThresholdForMandatory) { Set<Long> mandatoryCuboidSet = Sets.newHashSet(); if (hitFrequencyMap == null || hitFrequencyMap.isEmpty() || rollingUpCountSourceMap == null || rollingUpCountSourceMap.isEmpty()) { return mandatoryCuboidSet; } long totalHitFrequency = 0L; for (long hitFrequency : hitFrequencyMap.values()) { totalHitFrequency += hitFrequency; } if (totalHitFrequency == 0) { return mandatoryCuboidSet; } for (Map.Entry<Long, Long> hitFrequency : hitFrequencyMap.entrySet()) { long cuboid = hitFrequency.getKey(); if (statistics.get(cuboid) != null) { continue; } if (rollingUpCountSourceMap.get(cuboid) == null || rollingUpCountSourceMap.get(cuboid).isEmpty()) { continue; } long totalEstScanCount = 0L; for (long estScanCount : rollingUpCountSourceMap.get(cuboid).values()) { totalEstScanCount += estScanCount; } totalEstScanCount /= rollingUpCountSourceMap.get(cuboid).size(); if ((hitFrequency.getValue() * 1.0 / totalHitFrequency) * totalEstScanCount >= rollUpThresholdForMandatory) { mandatoryCuboidSet.add(cuboid); } } return mandatoryCuboidSet; }
From source file:eu.cloudwave.wp5.feedback.eclipse.base.core.handlers.HandlerToolkit.java
/** * Returns all projects that are currently selected. * // w w w .j av a2 s. c o m * @param event * {@link ExecutionEvent} * @return a {@link Set} containing all currently selected {@link IProject}'s */ public static Set<IProject> getSelectedProjects(final ExecutionEvent event) { final Set<IProject> selectedProjects = Sets.newHashSet(); final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (final Iterator<?> it = structuredSelection.iterator(); it.hasNext();) { final Object selectedElement = it.next(); if (selectedElement instanceof IProject) { selectedProjects.add((IProject) selectedElement); } else if (selectedElement instanceof IAdaptable) { selectedProjects.add((IProject) ((IAdaptable) selectedElement).getAdapter(IProject.class)); } } } return ImmutableSet.copyOf(selectedProjects); }
From source file:org.spdx.rdfparser.RdfModelHelper.java
/** * Compares 2 arrays to see if thier content is the same independent of * order and considering nulls//from w ww . j av a2 s . c o m * @param array1 * @param array2 * @return */ public static boolean arraysEqual(Object[] array1, Object[] array2) { if (array1 == null) { return array2 == null; } if (array2 == null) { return false; } if (array1.length != array2.length) { return false; } Set<Integer> foundIndexes = Sets.newHashSet(); for (int i = 0; i < array1.length; i++) { boolean found = false; for (int j = 0; j < array2.length; j++) { if (!foundIndexes.contains(j) && Objects.equal(array1[i], array2[j])) { found = true; foundIndexes.add(j); break; } } if (!found) { return false; } } return true; }
From source file:presto.android.gui.listener.ListenerRegistration.java
public ListenerRegistration(EventType eventType, String subsig, int position, SootClass listenerClass) { this.eventType = eventType; this.subsig = subsig; this.position = position; this.listenerClass = listenerClass; this.handlers = Sets.newHashSet(); }
From source file:org.terasology.world.generator.plugin.TempWorldGeneratorPluginLibrary.java
private static ModuleEnvironment getEnv() { ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class); AssetManager assetManager = CoreRegistry.get(AssetManager.class); Config config = CoreRegistry.get(Config.class); Set<Module> selectedModules = Sets.newHashSet(); for (Name moduleName : config.getDefaultModSelection().listModules()) { Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName); if (module != null) { selectedModules.add(module); for (DependencyInfo dependencyInfo : module.getMetadata().getDependencies()) { selectedModules.add(moduleManager.getRegistry().getLatestModuleVersion(dependencyInfo.getId())); }/*from www .j a v a 2s.c o m*/ } } ModuleEnvironment environment = moduleManager.loadEnvironment(selectedModules, false); assetManager.setEnvironment(environment); return environment; }
From source file:org.kiji.maven.plugins.BentoTestUtils.java
static void validateHdfs(final Configuration conf) throws URISyntaxException, IOException { final URI bentoHdfsUri = new URI("hdfs:///"); final FileSystem hdfs = FileSystem.get(bentoHdfsUri, conf); // Collect directory names. final Set<String> directoryNames = Sets.newHashSet(); for (final FileStatus file : hdfs.listStatus(new Path("/"))) { directoryNames.add(file.getPath().getName()); }/*from ww w . j av a 2 s . c o m*/ Assert.assertTrue("Bento HDFS must have /hbase/", directoryNames.contains("hbase")); Assert.assertTrue("Bento HDFS must have /user/", directoryNames.contains("user")); Assert.assertTrue("Bento HDFS must have /var/", directoryNames.contains("var")); Assert.assertTrue("Bento HDFS must have /tmp", directoryNames.contains("tmp")); }
From source file:org.s1ck.gdl.model.GraphElement.java
public GraphElement() { graphs = Sets.newHashSet(); }
From source file:edu.harvard.med.screensaver.io.parseutil.CsvSetColumn.java
@Override protected Set<E> parseField(String value) throws ParseException { Set<E> set = Sets.newHashSet(); if (value != null) { String[] values = value.split(DataExporter.LIST_DELIMITER, -1); for (String v : values) { if (!set.add(parseElement(v.trim()))) { throw new ParseException(new ParseError(getName() + " cannot contain duplicates: " + v)); }/*from w w w . j a v a2s. co m*/ } } return set; }