List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet()
From source file:me.smoe.adar.utils.cam.o.common.SentenceAnalyzer.java
public static Set<String> analyzer(String sentence) throws Exception { if (StringUtils.isEmpty(sentence)) { return Collections.emptySet(); }/*from ww w .j a v a2 s . co m*/ Analyzer analyzer = new StandardAnalyzer(); try { TokenStream tokenStream = analyzer.tokenStream(StringUtils.EMPTY, new StringReader(sentence)); tokenStream.addAttribute(CharTermAttribute.class); tokenStream.reset(); Set<String> words = new LinkedHashSet<>(); while (tokenStream.incrementToken()) { String word = ((CharTermAttribute) tokenStream.getAttribute(CharTermAttribute.class)).toString(); if (word.length() <= 1) { continue; } words.add(word); } return words; } finally { analyzer.close(); } }
From source file:Main.java
public static final Set<String> stringArrayToSet(final String[] array) { if (array == null) { return Collections.emptySet(); }// w w w . j av a2s. co m Set<String> tmp = new LinkedHashSet<>(); for (String part : array) { String trimmed = part.trim(); if (trimmed.length() > 0) { tmp.add(trimmed.intern()); } } return tmp; }
From source file:org.geoserver.wps.process.GeoServerProcessors.java
/** * Set of available ProcessFactory, each eventually wrapped or filtered out by the registered * {@link ProcessFilter}/*from w ww . j av a 2 s. c om*/ * * @return Set of ProcessFactory */ public static Set<ProcessFactory> getProcessFactories() { Set<ProcessFactory> factories = Processors.getProcessFactories(); Set<ProcessFactory> result = new LinkedHashSet<ProcessFactory>(); // scan filters and let them wrap and exclude as necessary for (ProcessFactory pf : factories) { pf = applyFilters(pf); if (pf != null) { result.add(pf); } } return result; }
From source file:edu.cornell.mannlib.vitro.webapp.web.templatemodels.Tags.java
public Tags() { this.tags = new LinkedHashSet<String>(); }
From source file:Randomizer.java
public int[] nextInt(int n, int size) { if (size > n) { size = n;/*from w w w . ja v a 2s. c om*/ } Set set = new LinkedHashSet(); for (int i = 0; i < size; i++) { while (true) { Integer value = new Integer(nextInt(n)); if (!set.contains(value)) { set.add(value); break; } } } int[] array = new int[set.size()]; Iterator itr = set.iterator(); for (int i = 0; i < array.length; i++) { array[i] = ((Integer) itr.next()).intValue(); } return array; }
From source file:ips1ap101.lib.core.app.OrdenConjuntoResultados.java
public OrdenConjuntoResultados() { criterios = new LinkedHashSet<>(); }
From source file:com.egt.core.aplicacion.OrdenConjuntoResultados.java
public OrdenConjuntoResultados() { criterios = new LinkedHashSet<CriterioOrden>(); }
From source file:Main.java
/** * <p>Gets a {@code List} of all interfaces implemented by the given * class and its superclasses.</p> * * <p>The order is determined by looking through each interface in turn as * declared in the source file and following its hierarchy up. Then each * superclass is considered in the same way. Later duplicates are ignored, * so the order is maintained.</p> * * @param cls the class to look up, may be {@code null} * @return the {@code List} of interfaces in order, * {@code null} if null input// w w w. ja va 2 s. com */ public static List<Class<?>> getAllInterfaces(Class<?> cls) { if (cls == null) { return null; } LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>(); getAllInterfaces(cls, interfacesFound); return new ArrayList<Class<?>>(interfacesFound); }
From source file:Main.java
/** * <p>Gets a {@code List} of all interfaces implemented by the given * class and its superclasses.</p> * * <p>The order is determined by looking through each interface in turn as * declared in the source file and following its hierarchy up. Then each * superclass is considered in the same way. Later duplicates are ignored, * so the order is maintained.</p> * * @param cls the class to look up, may be {@code null} * @return the {@code List} of interfaces in order, * {@code null} if null input// w ww . j ava 2 s .c om */ public static List<Class<?>> getAllInterfaces(final Class<?> cls) { if (cls == null) { return null; } final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>(); getAllInterfaces(cls, interfacesFound); return new ArrayList<Class<?>>(interfacesFound); }
From source file:Main.java
/** * Returns the array as a set/*from www . jav a 2 s . c o m*/ */ public static <T> LinkedHashSet<T> asLinkedHashSet(T[] array) { LinkedHashSet<T> set = new LinkedHashSet<T>(); for (T obj : array) { set.add(obj); } return set; }