List of usage examples for java.util HashSet remove
public boolean remove(Object o)
From source file:com.android.messaging.mmslib.util.PduCache.java
private void removeFromThreads(Uri key, PduCacheEntry entry) { HashSet<Uri> thread = mThreads.get(entry.getThreadId()); if (thread != null) { thread.remove(key); }/*from ww w.j ava 2 s .c om*/ }
From source file:org.trnltk.morphology.lexicon.LexemeCreator.java
private void inferNounOrAdjectiveMorphemicAttributes(String lemmaRoot, TurkicLetter lastLetter, int vowelCount, HashSet<LexemeAttribute> lexemeAttributes) { if (lexemeAttributes.contains(LexemeAttribute.VoicingOpt)) { lexemeAttributes.remove(LexemeAttribute.Voicing); lexemeAttributes.remove(LexemeAttribute.NoVoicing); } else {/*from ww w . j a v a 2 s. co m*/ if (vowelCount > 1 && lastLetter.isStopConsonant() && !lexemeAttributes.contains(LexemeAttribute.NoVoicing) && !lexemeAttributes.contains(LexemeAttribute.InverseHarmony)) lexemeAttributes.add(LexemeAttribute.Voicing); else if (lemmaRoot.endsWith("nk") || lemmaRoot.endsWith("og") || lemmaRoot.endsWith("rt")) lexemeAttributes.add(LexemeAttribute.Voicing); else if (!lexemeAttributes.contains(LexemeAttribute.Voicing)) lexemeAttributes.add(LexemeAttribute.NoVoicing); } }
From source file:com.android.messaging.mmslib.util.PduCache.java
private void removeFromMessageBoxes(Uri key, PduCacheEntry entry) { HashSet<Uri> msgBox = mThreads.get(Long.valueOf(entry.getMessageBox())); if (msgBox != null) { msgBox.remove(key); }//from w w w .j a va 2 s .com }
From source file:de.fau.cs.osr.hddiff.perfsuite.EditScriptAnalysis.java
private Object printNodeStatsByOp(GenericEditOp needle) { HashSet<String> tmp = new HashSet<>(editsByLabel.keySet()); tmp.remove(null); LinkedList<String> keys = new LinkedList<>(tmp); Collections.sort(keys);//from w ww . j a va 2s .com keys.add(null); StringBuilder b = new StringBuilder(); b.append(String.format(" %s by label:\n", needle)); boolean empty = true; for (String key : keys) { int count = 0; List<Edit> ops = editsByLabel.get(key); if (ops != null) for (Edit op : ops) { if (op.op == needle) ++count; } if (count > 0) { empty = false; if (key == null) key = "#text"; String paddedKey = StringUtils.rightPad(StringUtils.abbreviate(key, 16) + ":", 17); b.append(String.format(" %s %4d\n", paddedKey, count)); } } return empty ? "" : b.toString(); }
From source file:net.mybox.mybox.Server.java
/** * Remove a client connection from the server * @param handle// www .j av a 2 s. c om */ public void removeAndTerminateConnection(int handle) { ServerClientConnection toTerminate = clients.get(handle); if (toTerminate.account != null) { printMessage("Removing client " + handle + " (" + toTerminate.account.email + ")"); // update the client map HashSet<Integer> thisMap = multiClientMap.get(toTerminate.account.id); thisMap.remove(handle); multiClientMap.put(toTerminate.account.id, thisMap); } else printMessage("Removing null client " + handle); try { // stop the thread toTerminate.close(); } catch (IOException ioe) { printMessage("Error closing thread: " + ioe); } // remove from list clients.remove(handle); }
From source file:org.walkmod.conf.providers.yml.AddModulesYMLAction.java
@Override public void doAction(JsonNode node) throws Exception { ArrayNode aux = null;//from www . j a v a2 s . c o m HashSet<String> modulesToAdd = new HashSet<String>(modules); if (node.has("modules")) { JsonNode list = node.get("modules"); Iterator<JsonNode> it = list.iterator(); while (it.hasNext()) { JsonNode next = it.next(); modulesToAdd.remove(next.asText().trim()); } if (!modulesToAdd.isEmpty()) { if (list.isArray()) { aux = (ArrayNode) list; } } } else { aux = new ArrayNode(provider.getObjectMapper().getNodeFactory()); } if (!modulesToAdd.isEmpty()) { for (String moduleToAdd : modulesToAdd) { TextNode prov = new TextNode(moduleToAdd); aux.add(prov); } ObjectNode auxNode = (ObjectNode) node; auxNode.set("modules", aux); provider.write(node); } }
From source file:org.ecloudmanager.web.faces.DeploymentActionController.java
private void setStatusClass(CyNode node, Action.Status status) { String statusClass = status.name().toLowerCase(); HashSet<String> classes = Sets.newHashSet(node.getClasses().split(" ")); if (classes.contains(statusClass)) { return;/*w w w . jav a 2 s . co m*/ } HashSet<Action.Status> classesToRemove = Sets.newHashSet(Action.Status.values()); classesToRemove.remove(status); classes.removeAll( classesToRemove.stream().map(Enum::name).map(String::toLowerCase).collect(Collectors.toSet())); classes.add(statusClass); node.setClasses(StringUtils.join(classes, " ").trim()); }
From source file:com.haulmont.timesheets.global.ValidationTools.java
public ResultAndCause validateTags(TimeEntryBase timeEntry) { Preconditions.checkNotNullArgument(timeEntry); Preconditions.checkNotNullArgument(timeEntry.getTask()); Preconditions.checkNotNullArgument(timeEntry.getTask().getRequiredTagTypes()); HashSet<TagType> remainingRequiredTagTypes = new HashSet<>(timeEntry.getTask().getRequiredTagTypes()); if (CollectionUtils.isNotEmpty(timeEntry.getTags())) { for (Tag tag : timeEntry.getTags()) { remainingRequiredTagTypes.remove(tag.getTagType()); }//from www.ja v a2 s . c o m } if (remainingRequiredTagTypes.size() > 0) { StringBuilder stringBuilder = new StringBuilder(); for (TagType remainingRequiredTagType : remainingRequiredTagTypes) { stringBuilder.append(remainingRequiredTagType.getName()).append(","); } if (stringBuilder.length() > 0) { stringBuilder.deleteCharAt(stringBuilder.length() - 1);//remove last comma } return ResultAndCause.negative( messages.formatMessage(getClass(), "notification.requiredTagTypesNotPresent", stringBuilder)); } return ResultAndCause.positive(); }
From source file:org.apache.activemq.leveldb.test.ElectingLevelDBStoreTest.java
@Ignore("https://issues.apache.org/jira/browse/AMQ-5512") @Test(timeout = 1000 * 60 * 10)/*from www .ja v a2 s . c o m*/ public void testElection() throws Exception { deleteDirectory("leveldb-node1"); deleteDirectory("leveldb-node2"); deleteDirectory("leveldb-node3"); ArrayList<CountDownFuture> pending_starts = new ArrayList<CountDownFuture>(); for (String dir : new String[] { "leveldb-node1", "leveldb-node2", "leveldb-node3" }) { ElectingLevelDBStore store = createStoreNode(); store.setDirectory(new File(data_dir(), dir)); stores.add(store); pending_starts.add(asyncStart(store)); } // At least one of the stores should have started. CountDownFuture f = waitFor(30 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()])); assertTrue(f != null); pending_starts.remove(f); // The other stores should not start.. LOG.info("Making sure the other stores don't start"); Thread.sleep(5000); for (CountDownFuture start : pending_starts) { assertFalse(start.completed()); } // Make sure only of the stores is reporting to be the master. for (ElectingLevelDBStore store : stores) { if (store.isMaster()) { assertNull(master); master = store; } } assertNotNull(master); // We can work out who the slaves are... HashSet<ElectingLevelDBStore> slaves = new HashSet<ElectingLevelDBStore>(stores); slaves.remove(master); // Start sending messages to the master. ArrayList<String> expected_list = new ArrayList<String>(); MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST")); final int TOTAL = 500; for (int i = 0; i < TOTAL; i++) { if (i % ((int) (TOTAL * 0.10)) == 0) { LOG.info("" + (100 * i / TOTAL) + "% done"); } if (i == 250) { LOG.info("Checking master state"); assertEquals(expected_list, getMessages(ms)); // mid way, lets kill the master.. LOG.info("Killing Master."); master.stop(); // At least one of the remaining stores should complete starting. LOG.info("Waiting for slave takeover..."); f = waitFor(60 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()])); assertTrue(f != null); pending_starts.remove(f); // Make sure one and only one of the slaves becomes the master.. master = null; for (ElectingLevelDBStore store : slaves) { if (store.isMaster()) { assertNull(master); master = store; } } assertNotNull(master); slaves.remove(master); ms = master.createQueueMessageStore(new ActiveMQQueue("TEST")); } String msgid = "m:" + i; addMessage(ms, msgid); expected_list.add(msgid); } LOG.info("Checking master state"); ArrayList<String> messagesInStore = getMessages(ms); int index = 0; for (String id : expected_list) { if (!id.equals(messagesInStore.get(index))) { LOG.info("Mismatch for expected:" + id + ", got:" + messagesInStore.get(index)); break; } index++; } assertEquals(expected_list, messagesInStore); }
From source file:org.trnltk.morphology.lexicon.ImmutableRootGenerator.java
private HashSet<ImmutableRoot> generateModifiedRootNodes(final Lexeme lexeme) { final Set<LexemeAttribute> lexemeAttributes = lexeme.getAttributes(); if (lexemeAttributes.contains(LexemeAttribute.Special)) return this.handleSpecialRoots(lexeme); if (lexemeAttributes.contains(LexemeAttribute.EndsWithAyn)) { //kind of hack, didn't like it :( // if the word ends with Ayn // create roots with that attribute, and without that attribute // when creating with that attribute, add a VowelStart expectation final HashSet<ImmutableRoot> immutableRoots = new HashSet<ImmutableRoot>(); final EnumSet<LexemeAttribute> lexemeAttributesWithoutAyn = EnumSet.copyOf(lexemeAttributes); lexemeAttributesWithoutAyn.remove(LexemeAttribute.EndsWithAyn); final Lexeme lexemeWithoutAttrEndsWithAyn = new ImmutableLexeme(lexeme.getLemma(), lexeme.getLemmaRoot(), lexeme.getPrimaryPos(), lexeme.getSecondaryPos(), Sets.immutableEnumSet(lexemeAttributesWithoutAyn)); final HashSet<ImmutableRoot> rootsWithoutAynApplied = this .generateModifiedRootNodes(lexemeWithoutAttrEndsWithAyn); immutableRoots.addAll(rootsWithoutAynApplied); for (ImmutableRoot immutableRoot : rootsWithoutAynApplied) { final ImmutableSet<PhoneticAttribute> phoneticAttributesWithoutAynApplied = immutableRoot .getPhoneticAttributes(); final HashSet<PhoneticAttribute> phoneticAttributesWithAynApplied = Sets .newHashSet(phoneticAttributesWithoutAynApplied); phoneticAttributesWithAynApplied.remove(PhoneticAttribute.LastLetterVowel); phoneticAttributesWithAynApplied.add(PhoneticAttribute.LastLetterConsonant); final ImmutableRoot immutableRootWithAynApplied = new ImmutableRoot(immutableRoot.getSequence(), immutableRoot.getLexeme(), Sets.immutableEnumSet(phoneticAttributesWithAynApplied), Sets.immutableEnumSet(PhoneticExpectation.VowelStart)); immutableRoots.add(immutableRootWithAynApplied); }//w w w . j av a2 s . co m // just before returning, set correct lexeme again final HashSet<ImmutableRoot> immutableRootsWithCorrectLexemeAttr = new HashSet<ImmutableRoot>(); for (ImmutableRoot immutableRoot : immutableRoots) { immutableRootsWithCorrectLexemeAttr.add(new ImmutableRoot(immutableRoot.getSequence(), lexeme, immutableRoot.getPhoneticAttributes(), immutableRoot.getPhoneticExpectations())); } return immutableRootsWithCorrectLexemeAttr; } final String lemmaRoot = lexeme.getLemmaRoot(); String modifiedRootStr = lexeme.getLemmaRoot(); final EnumSet<PhoneticAttribute> originalPhoneticAttrs = phoneticsAnalyzer .calculatePhoneticAttributes(lexeme.getLemmaRoot(), null); final EnumSet<PhoneticAttribute> modifiedPhoneticAttrs = phoneticsAnalyzer .calculatePhoneticAttributes(lexeme.getLemmaRoot(), null); final EnumSet<PhoneticExpectation> originalPhoneticExpectations = EnumSet.noneOf(PhoneticExpectation.class); final EnumSet<PhoneticExpectation> modifiedPhoneticExpectations = EnumSet.noneOf(PhoneticExpectation.class); if (CollectionUtils.containsAny(lexemeAttributes, Sets.immutableEnumSet(LexemeAttribute.Voicing, LexemeAttribute.VoicingOpt))) { final TurkicLetter lastLetter = TurkishAlphabet .getLetter(modifiedRootStr.charAt(modifiedRootStr.length() - 1)); final TurkicLetter voicedLastLetter = lemmaRoot.endsWith("nk") ? TurkishAlphabet.L_g : TurkishAlphabet.voice(lastLetter); Validate.notNull(voicedLastLetter); modifiedRootStr = modifiedRootStr.substring(0, modifiedRootStr.length() - 1) + voicedLastLetter.charValue(); modifiedPhoneticAttrs.remove(PhoneticAttribute.LastLetterVoicelessStop); if (!lexemeAttributes.contains(LexemeAttribute.VoicingOpt)) { originalPhoneticExpectations.add(PhoneticExpectation.ConsonantStart); } modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } if (lexemeAttributes.contains(LexemeAttribute.Doubling)) { modifiedRootStr += modifiedRootStr.charAt(modifiedRootStr.length() - 1); originalPhoneticExpectations.add(PhoneticExpectation.ConsonantStart); modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } if (lexemeAttributes.contains(LexemeAttribute.LastVowelDrop)) { modifiedRootStr = modifiedRootStr.substring(0, modifiedRootStr.length() - 2) + modifiedRootStr.charAt(modifiedRootStr.length() - 1); if (!PrimaryPos.Verb.equals(lexeme.getPrimaryPos())) originalPhoneticExpectations.add(PhoneticExpectation.ConsonantStart); modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } if (lexemeAttributes.contains(LexemeAttribute.InverseHarmony)) { originalPhoneticAttrs.add(PhoneticAttribute.LastVowelFrontal); originalPhoneticAttrs.remove(PhoneticAttribute.LastVowelBack); modifiedPhoneticAttrs.add(PhoneticAttribute.LastVowelFrontal); modifiedPhoneticAttrs.remove(PhoneticAttribute.LastVowelBack); } if (lexemeAttributes.contains(LexemeAttribute.ProgressiveVowelDrop)) { modifiedRootStr = modifiedRootStr.substring(0, modifiedRootStr.length() - 1); if (this.hasVowel(modifiedRootStr)) { modifiedPhoneticAttrs.clear(); modifiedPhoneticAttrs.addAll(phoneticsAnalyzer.calculatePhoneticAttributes(modifiedRootStr, null)); } modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } ImmutableRoot originalRoot = new ImmutableRoot(lexeme.getLemmaRoot(), lexeme, Sets.immutableEnumSet(originalPhoneticAttrs), Sets.immutableEnumSet(originalPhoneticExpectations)); ImmutableRoot modifiedRoot = new ImmutableRoot(modifiedRootStr, lexeme, Sets.immutableEnumSet(modifiedPhoneticAttrs), Sets.immutableEnumSet(modifiedPhoneticExpectations)); if (originalRoot.equals(modifiedRoot)) return Sets.newHashSet(originalRoot); else return Sets.newHashSet(originalRoot, modifiedRoot); }