List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:com.strider.datadefender.FileDiscoverer.java
private static List<FileMatchMetaData> uniqueList(List<FileMatchMetaData> finalList) { HashSet hs = new HashSet(); hs.addAll(finalList); finalList.clear();// w ww . j a v a 2s .com finalList.addAll(hs); return finalList; }
From source file:edu.isistan.carcha.util.PluginUtil.java
/** * Removes the duplicates./*from www. jav a 2 s. co m*/ * * @param concerns the concerns */ public static void removeDuplicates(List<Entity> concerns) { ArrayList<Entity> ret = new ArrayList<Entity>(); HashSet<Entity> hash = new HashSet<Entity>(); hash.addAll(concerns); ret.clear(); ret.addAll(hash); }
From source file:nl.b3p.kaartenbalie.service.LayerTreeSupport.java
public static JSONObject createWfsTree(EntityManager em, String rootName, Set organizationLayers, boolean checkLayers) throws Exception { JSONObject root = new JSONObject(); root.put("name", rootName); root.put("id", "wfs" + rootName); List serviceProviders = em.createQuery("from WfsServiceProvider sp order by sp.abbr").getResultList(); JSONArray rootArray = new JSONArray(); Iterator it = serviceProviders.iterator(); while (it.hasNext()) { WfsServiceProvider sp = (WfsServiceProvider) it.next(); JSONObject parentObj = LayerTreeSupport.serviceProviderToJSON(sp); HashSet set = new HashSet(); Set layers = sp.getWfsLayers(); set.addAll(layers); parentObj = LayerTreeSupport.createWfsTreeList(set, organizationLayers, parentObj, checkLayers); if (parentObj.has("children")) { rootArray.put(parentObj);//from w ww . j a v a2 s . c o m } } root.put("children", rootArray); return root; }
From source file:org.jamocha.dn.memory.javaimpl.MemoryHandlerMain.java
public static org.jamocha.dn.memory.MemoryHandlerMainAndCounterColumnMatcher newMemoryHandlerMain( final PathNodeFilterSet filterSet, final Map<Edge, Set<Path>> edgesAndPaths) { final ArrayList<Template> template = new ArrayList<>(); final ArrayList<FactAddress> addresses = new ArrayList<>(); final HashMap<FactAddress, FactAddress> newAddressesCache = new HashMap<>(); if (!edgesAndPaths.isEmpty()) { final Edge[] incomingEdges = edgesAndPaths.entrySet().iterator().next().getKey().getTargetNode() .getIncomingEdges();//from w w w.ja v a 2 s . com for (final Edge edge : incomingEdges) { final MemoryHandlerMain memoryHandlerMain = (MemoryHandlerMain) edge.getSourceNode().getMemory(); for (final Template t : memoryHandlerMain.getTemplate()) { template.add(t); } final HashMap<FactAddress, FactAddress> addressMap = new HashMap<>(); for (final FactAddress oldFactAddress : memoryHandlerMain.addresses) { final FactAddress newFactAddress = new FactAddress(addresses.size()); addressMap.put(oldFactAddress, newFactAddress); newAddressesCache.put(oldFactAddress, newFactAddress); addresses.add(newFactAddress); } edge.setAddressMap(addressMap); } } final Template[] templArray = toArray(template, Template[]::new); final FactAddress[] addrArray = toArray(addresses, FactAddress[]::new); final PathFilterToCounterColumn pathFilterToCounterColumn = new PathFilterToCounterColumn(); if (filterSet.getPositiveExistentialPaths().isEmpty() && filterSet.getNegativeExistentialPaths().isEmpty()) { return new MemoryHandlerMainAndCounterColumnMatcher(new MemoryHandlerMain(templArray, Counter.newCounter(filterSet, pathFilterToCounterColumn), addrArray), pathFilterToCounterColumn); } final boolean[] existential = new boolean[templArray.length]; // gather existential paths final HashSet<Path> existentialPaths = new HashSet<>(); existentialPaths.addAll(filterSet.getPositiveExistentialPaths()); existentialPaths.addAll(filterSet.getNegativeExistentialPaths()); int index = 0; for (final PathFilter pathFilter : filterSet.getFilters()) { final HashSet<Path> paths = PathCollector.newHashSet().collect(pathFilter).getPaths(); paths.retainAll(existentialPaths); if (0 == paths.size()) continue; for (final Path path : paths) { existential[newAddressesCache.get(path.getFactAddressInCurrentlyLowestNode()).index] = true; } pathFilterToCounterColumn.putFilterElementToCounterColumn(pathFilter, new CounterColumn(index++)); } return new MemoryHandlerMainAndCounterColumnMatcher( new MemoryHandlerMainWithExistentials(templArray, Counter.newCounter(filterSet, pathFilterToCounterColumn), addrArray, existential), pathFilterToCounterColumn); }
From source file:org.droidparts.inner.PersistUtils.java
public static ArrayList<String> getDropTables(SQLiteDatabase db, String... optionalTableNames) { HashSet<String> tableNames = new HashSet<String>(); if (optionalTableNames.length == 0) { tableNames.addAll(getTableNames(db)); } else {/* w w w. j a v a 2 s .c o m*/ tableNames.addAll(asList(optionalTableNames)); } ArrayList<String> statements = new ArrayList<String>(); for (String tableName : tableNames) { statements.add("DROP TABLE IF EXISTS " + tableName + ";"); } return statements; }
From source file:de.steilerdev.myVerein.server.model.Division.java
/** * This function expands the set of divisions. This means that every division, the user is part of (all child divisions of every division) are going to be returned. * @param initialSetOfDivisions The set of divisions that needs to be expanded. * @param divisionRepository The division repository, needed to get queried. * @return The expanded list of divisions. *//*w w w .j a v a2 s .co m*/ @JsonIgnore @Transient public static List<Division> getExpandedSetOfDivisions(List<Division> initialSetOfDivisions, DivisionRepository divisionRepository) { if ((initialSetOfDivisions = getOptimizedSetOfDivisions(initialSetOfDivisions)) == null) { logger.warn("Trying to expand a set of divisions, but initial set is either null or empty"); return null; } else { logger.debug("Expanding division set"); HashSet<Division> expandedSetOfDivisions = new HashSet<>(); for (Division division : initialSetOfDivisions) { expandedSetOfDivisions.addAll(divisionRepository.findByAncestors(division)); expandedSetOfDivisions.add(divisionRepository.findById(division.getId())); } return new ArrayList<>(expandedSetOfDivisions); } }
From source file:com.ejisto.util.IOUtils.java
public static Collection<String> findAllWebApplicationClasses(String basePath, WebApplicationDescriptor descriptor) throws IOException { HashSet<String> ret = new HashSet<>(); File webInf = new File(basePath, "WEB-INF"); ret.addAll(findAllClassNamesInDirectory(new File(webInf, "classes"))); ret.addAll(findAllClassNamesInJarDirectory(new File(webInf, "lib"), descriptor)); return ret;/*from w ww . j a v a2s .c o m*/ }
From source file:core.Utility.java
private static ArrayList<String> getSynonymsWordnet(String _word) { ArrayList<String> _list = new ArrayList(); File f = new File("WordNet\\2.1\\dict"); System.setProperty("wordnet.database.dir", f.toString()); WordNetDatabase database = WordNetDatabase.getFileInstance(); Synset[] synsets = database.getSynsets(_word); if (synsets.length > 0) { HashSet hs = new HashSet(); for (Synset synset : synsets) { String[] wordForms = synset.getWordForms(); _list.addAll(Arrays.asList(wordForms)); }//from ww w . j av a2s. c om hs.addAll(_list); _list.clear(); _list.addAll(hs); } return _list; }
From source file:com.ejisto.util.IOUtils.java
private static Collection<String> findAllClassNamesInJarDirectory(File directory, WebApplicationDescriptor descriptor) throws IOException { HashSet<String> ret = new HashSet<>(); for (File file : getAllFiles(directory, jarExtension)) { if (!descriptor.isBlacklistedEntry(file.getName())) { ret.addAll(findAllClassesInJarFile(file)); }/*from w w w.j av a2 s . c o m*/ } return ret; }
From source file:com.taobao.android.tpatch.utils.PatchUtils.java
private static Map<String, ClassDef> getBundleClassDef(File file) throws IOException { HashMap<String, ClassDef> classDefMap = new HashMap<String, ClassDef>(); File[] dexFiles = getDexFiles(file); HashSet<ClassDef> classDefs = new HashSet<ClassDef>(); for (File dexFile : dexFiles) { classDefs.addAll(DexFileFactory.loadDexFile(dexFile, 19, true).getClasses()); }//from www. j a v a2 s.c om for (ClassDef classDef : classDefs) { classDefMap.put(classDef.getType(), classDef); } return classDefMap; }