List of usage examples for com.google.common.collect Multiset elementSet
Set<E> elementSet();
From source file:com.intellij.find.impl.FindInProjectTask.java
private static void logStats(Collection<PsiFile> otherFiles, long start) { long time = System.currentTimeMillis() - start; final Multiset<String> stats = HashMultiset.create(); for (PsiFile file : otherFiles) { //noinspection StringToUpperCaseOrToLowerCaseWithoutLocale stats.add(StringUtil.notNullize(file.getViewProvider().getVirtualFile().getExtension()).toLowerCase()); }//ww w . j a v a 2 s. co m List<String> extensions = ContainerUtil.newArrayList(stats.elementSet()); Collections.sort(extensions, new Comparator<String>() { @Override public int compare(String o1, String o2) { return stats.count(o2) - stats.count(o1); } }); String message = "Search in " + otherFiles.size() + " files with unknown types took " + time + "ms.\n" + "Mapping their extensions to an existing file type (e.g. Plain Text) might speed up the search.\n" + "Most frequent non-indexed file extensions: "; for (int i = 0; i < Math.min(10, extensions.size()); i++) { String extension = extensions.get(i); message += extension + "(" + stats.count(extension) + ") "; } LOG.info(message); }
From source file:org.datacleaner.components.machinelearning.impl.MLFeatureUtils.java
public static Set<String> sanitizeFeatureVectorSet(Multiset<String> values, MLTrainingConstraints constraints) { final Set<String> resultSet; final int maxFeatures = constraints.getMaxFeatures(); if (maxFeatures > 0) { resultSet = new TreeSet<>(); final Iterator<String> highestCountFirst = Multisets.copyHighestCountFirst(values).elementSet() .iterator();// w ww . j av a 2s . c o m // populate "resultSet" using "highestCountFirst" for (int i = 0; i < maxFeatures; i++) { if (highestCountFirst.hasNext()) { final String value = highestCountFirst.next(); resultSet.add(value); } } } else { resultSet = new TreeSet<>(values.elementSet()); } final boolean includeFeaturesForUniqueValues = constraints.isIncludeFeaturesForUniqueValues(); if (!includeFeaturesForUniqueValues) { // remove uniques in "values" from "resultSet". for (Iterator<String> it = resultSet.iterator(); it.hasNext();) { final String value = it.next(); if (values.count(value) == 1) { it.remove(); } } } return resultSet; }
From source file:eu.esdihumboldt.hale.common.instance.index.PropertyEntityDefinitionMapping.java
/** * @see eu.esdihumboldt.hale.common.instance.index.IndexMapping#map(java.lang.Object) *//*from w ww .j a va 2s . co m*/ @Override public List<IndexedPropertyValue> map(Instance instance) { List<IndexedPropertyValue> result = new ArrayList<>(); for (PropertyEntityDefinition definition : definitions) { List<QName> propertyPath = definition.getPropertyPath().stream().map(cctx -> cctx.getChild().getName()) .collect(Collectors.toList()); Multiset<?> values = AlignmentUtil.getValues(instance, definition, false); result.add(new IndexedPropertyValue(propertyPath, values.elementSet().stream() .map(v -> processValue(v, definition)).collect(Collectors.toList()))); } return result; }
From source file:org.caleydo.view.domino.internal.data.Categorical2DDataDomainValues.java
/** * @param col/*from w w w . j av a 2s . c om*/ * @return */ private <T> T mostFrequent(Multiset<T> col) { T top = null; int c = 0; for (T elem : col.elementSet()) { int elemC = col.count(elem); if (elemC > c) { top = elem; c = elemC; } } return top; }
From source file:org.eclipse.viatra.query.runtime.base.core.NavigationHelperContentAdapter.java
/** * Decodes the collection of holders (potentially non-unique) to a unique set *///from ww w. ja va2s. c o m protected static Set<EObject> holderCollectionToUniqueSet(Collection<EObject> holders) { if (holders instanceof Set<?>) { return (Set<EObject>) holders; } else if (holders instanceof Multiset<?>) { Multiset<EObject> multiSet = (Multiset<EObject>) holders; return multiSet.elementSet(); } else throw new IllegalStateException("Neither Set nor Multiset: " + holders); }
From source file:org.deeplearning4j.eval.ConfusionMatrix.java
/** * Adds the entries from another confusion matrix to this one. *///from w ww . j a v a 2s. c o m public void add(ConfusionMatrix<T> other) { for (T actual : other.matrix.keySet()) { Multiset<T> counts = other.matrix.get(actual); for (T predicted : counts.elementSet()) { int count = counts.count(predicted); this.add(actual, predicted, count); } } }
From source file:com.google.inject.internal.WeakKeySet.java
public Set<Object> getSources(Key<?> key) { evictionCache.cleanUp();/*from w w w .j a v a2 s .c o m*/ Multiset<Object> sources = (backingMap == null) ? null : backingMap.get(new BlacklistKey(key)); return (sources == null) ? null : sources.elementSet(); }
From source file:org.eclipse.gef4.zest.fx.behaviors.HidingBehavior.java
protected void hide() { // hide visual getHost().getVisual().setVisible(false); getHost().getVisual().setMouseTransparent(true); // hide connections Multiset<IVisualPart<Node, ? extends Node>> anchoreds = getHost().getAnchoreds(); for (IVisualPart<Node, ? extends Node> anchored : anchoreds.elementSet()) { if (anchored instanceof EdgeContentPart) { anchored.refreshVisual();/*from w w w. jav a2 s . c o m*/ } } }
From source file:org.eclipse.gef4.zest.fx.behaviors.HidingBehavior.java
protected void show() { // show node/* w w w . j a va 2 s .c o m*/ getHost().getVisual().setVisible(true); getHost().getVisual().setMouseTransparent(false); // show connections Multiset<IVisualPart<Node, ? extends Node>> anchoreds = getHost().getAnchoreds(); for (IVisualPart<Node, ? extends Node> anchored : anchoreds.elementSet()) { if (anchored instanceof EdgeContentPart) { anchored.refreshVisual(); } } }
From source file:edu.berkeley.compbio.ml.MultiClassCrossValidationResults.java
public int numPredictedLabels() { final Set<L> predictedLabels = new HashSet<L>(); for (final Multiset<L> ls : confusionMatrix.values()) { predictedLabels.addAll(ls.elementSet()); }/* w w w .jav a2 s . com*/ return predictedLabels.size(); }