List of usage examples for java.util HashSet remove
public boolean remove(Object o)
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println(hSet);/*from ww w . ja v a 2s . c o m*/ boolean blnRemoved = hSet.remove(new Integer("2")); System.out.println(blnRemoved); System.out.println(hSet); }
From source file:Main.java
public static void main(String args[]) { HashSet<String> newset = new HashSet<String>(); newset.add("Learning"); newset.add("from"); newset.add("java2s.com"); System.out.println("Values before remove: " + newset); // remove "Easy" from set boolean isremoved = newset.remove("from"); System.out.println("Return value after remove: " + isremoved); System.out.println("Values after remove: " + newset); }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); System.out.println("Size of HashSet : " + hSet.size()); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println(hSet.size()); hSet.remove(new Integer("1")); System.out.println(hSet.size()); }
From source file:nl.systemsgenetics.genenetworkbackend.div.CreateCgdMatrix.java
/** * @param args the command line arguments * @throws java.io.FileNotFoundException *//*w ww . ja va2s.c o m*/ public static void main(String[] args) throws FileNotFoundException, IOException { final File cgdFile = new File("C:\\UMCG\\Genetica\\Projects\\GeneNetwork\\CGD.txt"); final File cgdMatrixFile = new File("C:\\UMCG\\Genetica\\Projects\\GeneNetwork\\CGD_matrix.txt"); final CSVParser parser = new CSVParserBuilder().withSeparator('\t').withIgnoreQuotations(true).build(); final CSVReader reader = new CSVReaderBuilder(new BufferedReader(new FileReader(cgdFile))).withSkipLines(1) .withCSVParser(parser).build(); HashSet<String> cgdInfo = new HashSet<>(30); cgdInfo.add("AD"); cgdInfo.add("AD"); cgdInfo.add("XL"); cgdInfo.add("Pediatric"); HashMap<String, HashSet<String>> geneInfoMap = new HashMap<>(); String[] nextLine; while ((nextLine = reader.readNext()) != null) { HashSet<String> geneInfo = new HashSet<>(); geneInfoMap.put(nextLine[0], geneInfo); String diseaseManifistationField = nextLine[7]; String[] diseaseManifistations = StringUtils.split(diseaseManifistationField, ';'); geneInfo.add(nextLine[4].trim()); geneInfo.add(nextLine[5].trim()); for (int i = 0; i < diseaseManifistations.length; ++i) { diseaseManifistations[i] = diseaseManifistations[i].trim(); cgdInfo.add(diseaseManifistations[i]); geneInfo.add(diseaseManifistations[i]); } } cgdInfo.remove("General"); DoubleMatrixDataset<String, String> cgdInfoTable = new DoubleMatrixDataset<>(geneInfoMap.keySet(), cgdInfo); for (Map.Entry<String, HashSet<String>> geneInfoEntry : geneInfoMap.entrySet()) { String gene = geneInfoEntry.getKey(); HashSet<String> geneInfo = geneInfoEntry.getValue(); for (String geneProperty : geneInfo) { if (cgdInfoTable.containsCol(geneProperty)) { cgdInfoTable.setElement(gene, geneProperty, 1); } } } cgdInfoTable.save(cgdMatrixFile); }
From source file:Main.java
/** * Null safe creation of a {@link HashSet} out of a given collection without <code>null</code> elements. The returned * {@link HashSet} is modifiable and never null. * * @param c/* w ww .java 2s.c o m*/ * @return an {@link HashSet} containing the given collection's elements without <code>null</code> elements. Never * null. */ public static <T> HashSet<T> hashSetWithoutNullElements(Collection<? extends T> c) { HashSet<T> set = hashSet(c); set.remove(null); return set; }
From source file:Main.java
public static <T> List<T> updateList(List<T> toBeUpdated, HashSet<T> updates) { HashSet<T> toBeUpdatedHashSet = new HashSet<T>(toBeUpdated); for (T id : updates) { if (toBeUpdatedHashSet.contains(id)) { toBeUpdatedHashSet.remove(id); } else {//from w w w. ja v a 2 s . co m toBeUpdatedHashSet.add(id); } } return new ArrayList<T>(toBeUpdatedHashSet); }
From source file:fr.simon.marquis.secretcodes.util.Utils.java
public static boolean addSecretCode(Context ctx, SecretCode value) { HashSet<SecretCode> secretCodes = new HashSet<SecretCode>(getSecretCodes(ctx)); boolean exist = secretCodes.contains(value); if (exist) {//from w ww .j a v a 2 s .c om secretCodes.remove(value); } secretCodes.add(value); saveSecretCodes(ctx, new ArrayList<SecretCode>(secretCodes)); return !exist; }
From source file:com.jetyun.pgcd.rpc.localarg.LocalArgController.java
/** * Unregisters a LocalArgResolver</b>. * //from ww w . j a v a2s. c o m * @param argClazz * The previously registered local class * @param argResolver * The previously registered LocalArgResolver object * @param contextInterface * The previously registered transport Context interface. */ public static void unregisterLocalArgResolver(Class argClazz, Class contextInterface, LocalArgResolver argResolver) { synchronized (localArgResolverMap) { HashSet resolverSet = (HashSet) localArgResolverMap.get(argClazz); if (resolverSet == null || !resolverSet.remove(new LocalArgResolverData(argResolver, argClazz, contextInterface))) { log.warn("local arg resolver " + argResolver.getClass().getName() + " not registered for local class " + argClazz.getName() + " with context " + contextInterface.getName()); return; } if (resolverSet.isEmpty()) { localArgResolverMap.remove(argClazz); } } log.info("unregistered local arg resolver " + argResolver.getClass().getName() + " for local class " + argClazz.getName() + " with context " + contextInterface.getName()); }
From source file:pt.webdetails.cda.test.util.CdaTestHelper.java
@SafeVarargs public static <T> boolean columnContains(TableModel table, int colIdx, T... values) { HashSet<T> set = new HashSet<T>(); set.addAll(Arrays.asList(values)); for (int i = 0; i < table.getRowCount(); i++) { set.remove(table.getValueAt(i, colIdx)); if (set.isEmpty()) { return true; }/*from www.jav a 2 s.c o m*/ } return false; }
From source file:com.googlecode.eyesfree.brailleback.FocusFinder.java
public static AccessibilityNodeInfoCompat findLastFocusableDescendant(AccessibilityNodeInfoCompat root, Context context) {//from www .jav a2 s . c om // null guard and shortcut for leaf nodes. if (root == null || root.getChildCount() <= 0) { return null; } HashSet<AccessibilityNodeInfoCompat> seenNodes = new HashSet<AccessibilityNodeInfoCompat>(); seenNodes.add(root); try { return findLastFocusableDescendantInternal(root, context, seenNodes); } finally { seenNodes.remove(root); // Not owned by us. AccessibilityNodeInfoUtils.recycleNodes(seenNodes); } }