List of usage examples for com.google.common.collect Sets newHashSet
public static <E> HashSet<E> newHashSet()
From source file:org.apache.mahout.fpm.pfpgrowth.dataset.KeyBasedStringTupleCombiner.java
@Override protected void reduce(Text key, Iterable<StringTuple> values, Context context) throws IOException, InterruptedException { Set<String> outputValues = Sets.newHashSet(); for (StringTuple value : values) { outputValues.addAll(value.getEntries()); }/*w ww.j av a2 s. c o m*/ context.write(key, new StringTuple(outputValues)); }
From source file:com.skcraft.launcher.creator.controller.task.DirectoryWalker.java
@Override public List<File> call() throws IOException { if (!dir.isDirectory()) { throw new IllegalArgumentException(dir.getAbsolutePath() + " is not a directory"); }// w ww .jav a 2 s . co m List<File> matched = Lists.newArrayList(); Set<String> seen = Sets.newHashSet(); Queue<File> queue = new LinkedList<>(); queue.add(dir); File cur; while ((cur = queue.poll()) != null) { String canonical = cur.getCanonicalPath(); if (!seen.contains(canonical) && MorePaths.isSubDirectory(dir, cur)) { File[] files = cur.listFiles(); if (files != null) { for (File file : files) { if (recursive && file.isDirectory()) { queue.add(file); } if (fileFilter.accept(file)) { matched.add(file); } } } } } return matched; }
From source file:org.eclipse.viatra.query.runtime.registry.impl.RegistryChangeMultiplexer.java
/** * Creates a new instance of the multiplexer. */ public RegistryChangeMultiplexer() { this.listeners = Sets.newHashSet(); }
From source file:org.onosproject.ovsdb.rfc.schema.type.RealBaseType.java
/** * Constructs a RealBaseType object./* ww w.j a v a2s. c o m*/ */ public RealBaseType() { this.min = Double.MIN_VALUE; this.max = Double.MAX_VALUE; this.enums = Sets.newHashSet(); }
From source file:org.eclipse.viatra.query.patternlanguage.emf.types.judgements.TypeJudgement.java
@Override public Set<Expression> getDependingExpressions() { return Sets.newHashSet(); }
From source file:com.palantir.atlasdb.keyvalue.rocksdb.impl.TimestampRangeIterator.java
@Override protected Set<Long> processCell(Pair<Cell, Long> cellAndInitialTs) { Cell cell = cellAndInitialTs.lhSide; Set<Long> ret = Sets.newHashSet(); if (cellAndInitialTs.rhSide < maxTimestamp) { ret.add(cellAndInitialTs.rhSide); }/*from www. j av a 2s . co m*/ for (it.next(); it.isValid(); it.next()) { Pair<Cell, Long> cellAndTs = RocksDbKeyValueServices.parseCellAndTs(it.key()); if (!cellAndTs.lhSide.equals(cell)) { break; } if (cellAndTs.rhSide < maxTimestamp) { ret.add(cellAndTs.rhSide); } } return ret.isEmpty() ? null : ret; }
From source file:org.onosproject.ovsdb.rfc.schema.type.IntegerBaseType.java
/** * Constructs a IntegerBaseType object.//from w w w.j av a 2s . co m */ public IntegerBaseType() { this.min = Integer.MIN_VALUE; this.max = Integer.MAX_VALUE; this.enums = Sets.newHashSet(); }
From source file:eu.project.ttc.utils.TermIndexUtils.java
public static Set<TermVariation> selectTermVariations(TermIndex termIndex, VariationType... types) { Set<TermVariation> selected = Sets.newHashSet(); for (TermVariation tv : getVariations(termIndex)) for (VariationType type : types) if (tv.getVariationType() == type) selected.add(tv);//w w w. j a v a 2 s .c o m return selected; }
From source file:com.textocat.textokit.morph.dictionary.MorphDictionaryAPIFactory.java
private static synchronized void initialize() { if (defaultApi != null) { return;//from w w w.ja v a 2 s . c o m } log.info("Searching for MorphDictionaryAPI implementations..."); Set<String> implClassNames = Sets.newHashSet(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); try { for (Resource implDeclRes : resolver .getResources("classpath*:META-INF/uima-ext/morph-dictionary-impl.txt")) { InputStream is = implDeclRes.getInputStream(); try { String implClassName = IOUtils.toString(is, "UTF-8").trim(); if (!implClassNames.add(implClassName)) { throw new IllegalStateException( String.format( "The classpath contains duplicate declaration of implementation '%s'. " + "Last one has been read from %s.", implClassName, implDeclRes.getURL())); } } finally { IOUtils.closeQuietly(is); } } } catch (IOException e) { throw new IllegalStateException(e); } if (implClassNames.isEmpty()) { throw new IllegalStateException(String.format("Can't find an implementation of MorphDictionaryAPI")); } if (implClassNames.size() > 1) { throw new IllegalStateException(String.format("More than one implementations have been found:\n%s\n" + "Adjust the app classpath or get an implementation by ID.", implClassNames)); } String implClassName = implClassNames.iterator().next(); log.info("Found MorphDictionaryAPI implementation: {}", implClassName); try { @SuppressWarnings("unchecked") Class<? extends MorphDictionaryAPI> implClass = (Class<? extends MorphDictionaryAPI>) Class .forName(implClassName); defaultApi = implClass.newInstance(); } catch (Exception e) { throw new IllegalStateException("Can't instantiate the MorphDictionaryAPI implementation", e); } }