本文整理了Java中java.util.HashSet.remove()
方法的一些代码示例,展示了HashSet.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashSet.remove()
方法的具体详情如下:
包路径:java.util.HashSet
类名称:HashSet
方法名:remove
[英]Removes the specified object from this HashSet.
[中]从此哈希集中删除指定的对象。
代码示例来源:origin: opentripplanner/OpenTripPlanner
public void setMonitoring(String key, boolean on) {
if (on) {
monitoring.add(key);
} else {
monitoring.remove(key);
}
}
}
代码示例来源:origin: loklak/loklak_server
@Override
public String getQuery() {
String query = this.queries.iterator().next();
this.queries.remove(query);
return query;
}
代码示例来源:origin: robolectric/robolectric
@Implementation(minSdk = LOLLIPOP)
protected void removeDefaultNetworkActiveListener(ConnectivityManager.OnNetworkActiveListener l) {
if (l == null) {
throw new IllegalArgumentException("Invalid OnNetworkActiveListener");
}
if (onNetworkActiveListeners.contains(l)) {
onNetworkActiveListeners.remove(l);
}
}
代码示例来源:origin: apache/geode
Iterator iterGrantorSerialNumbers = rmtGrantorSerialNumbers.iterator();
while (iterGrantorServices.hasNext()) {
String serviceName = (String) iterGrantorServices.next();
long versionId = ((Long) iterGrantorVersions.next()).longValue();
int serialNumber = ((Integer) iterGrantorSerialNumbers.next()).intValue();
GrantorInfo oldgi = (GrantorInfo) this.grantors.get(serviceName);
if (oldgi == null || oldgi.getVersionId() < versionId) {
this.grantors.put(serviceName, new GrantorInfo(rmtId, versionId, serialNumber, false));
this.crashedGrantors.remove(serviceName);
String serviceName = (String) it.next();
if (!this.grantors.containsKey(serviceName)) {
this.crashedGrantors.add(serviceName);
代码示例来源:origin: stackoverflow.com
outEdges.add(e);
node.inEdges.add(e);
return this;
for(Node n : allNodes){
if(n.inEdges.size() == 0){
S.add(n);
while(!S.isEmpty()){
Node n = S.iterator().next();
S.remove(n);
Edge e = it.next();
Node m = e.to;
m.inEdges.remove(e);//Remove edge from m
if(m.inEdges.isEmpty()){
S.add(m);
if(!n.inEdges.isEmpty()){
cycle = true;
break;
代码示例来源:origin: Sable/soot
Object s = it.next();
changedUnitsSet.remove(s);
Object obj = predIt.next();
JPegStmt stmt = (JPegStmt) predIt.next();
if (stmt.equals(obj)) {
Object succ = succIt.next();
if (!changedUnitsSet.contains(succ)) {
changedUnits.addLast(succ);
changedUnitsSet.add(succ);
代码示例来源:origin: apache/activemq
HashSet<String> hs = sd.ackPositions.get(sequenceId);
if (hs != null) {
hs.remove(subscriptionKey);
if (hs.isEmpty()) {
HashSet<String> firstSet = sd.ackPositions.values().iterator().next();
sd.ackPositions.remove(sequenceId);
Entry<Long, MessageRecord> entry = iterator.next();
if (entry.getKey().compareTo(sequenceId) <= 0) {
代码示例来源:origin: Sable/soot
Iterator keyIt = keylist.iterator();
while (keyIt.hasNext()) {
Object key = keyIt.next();
if (key instanceof ArrayRef) {
outset.remove(key);
Iterator keyIt = keylist.iterator();
while (keyIt.hasNext()) {
Object key = keyIt.next();
if (key instanceof ArrayRef) {
Value base = ((ArrayRef) key).getBase();
outset.remove(key);
Object base = ((Array2ndDimensionSymbol) key).getVar();
if (base.equals(local)) {
outset.remove(key);
Iterator condIt = condset.iterator();
while (condIt.hasNext()) {
if (inset.contains(condIt.next())) {
outset.addAll(genset);
break;
代码示例来源:origin: greenrobot/essentials
@Override
public void run() {
final HashSet<Long> set = new HashSet<>(initialCapacity);
final long[] values = this.values;
for (int i = 0; i < N; i++) {
set.add(values[i]);
}
// check contains on every second key and remove it
for (int i = 0; i < N; i++) {
final long key = values[i] + i % 2;
if (set.contains(key)) {
set.remove(key);
}
}
// remove the rest
for (int i = 0; i < N; i++) {
final long key = values[i];
if (set.contains(key)) {
set.remove(key);
}
}
}
代码示例来源:origin: ankidroid/Anki-Android
private void onCheck(int position, View cell) {
CheckBox checkBox = (CheckBox) cell.findViewById(R.id.card_checkbox);
if (checkBox.isChecked()) {
mCheckedCardPositions.add(position);
} else {
mCheckedCardPositions.remove(position);
}
updateMultiselectMenu();
if (mCheckedCardPositions.isEmpty()) {
// when 0 are selected: end selection mode
endMultiSelectMode();
} else {
mActionBarTitle.setText(Integer.toString(mCheckedCardPositions.size()));
}
}
代码示例来源:origin: fesh0r/fernflower
setHandlers.add(head);
while (true) {
if (setNodes.contains(handler)) {
continue;
Statement st = lstStack.remove(0);
if (!(setNodes.contains(st) || (!same && st == post))) {
setNodes.add(st);
if (st != head) {
setHandlers.remove(handler);
break;
代码示例来源:origin: fesh0r/fernflower
public HashSet<Statement> buildContinueSet() {
continueSet.clear();
for (Statement st : stats) {
continueSet.addAll(st.buildContinueSet());
if (st != first) {
continueSet.remove(st.getBasichead());
}
}
for (StatEdge edge : getEdges(StatEdge.TYPE_CONTINUE, DIRECTION_FORWARD)) {
continueSet.add(edge.getDestination().getBasichead());
}
if (type == TYPE_DO) {
continueSet.remove(first.getBasichead());
}
return continueSet;
}
代码示例来源:origin: apache/mahout
switch (randomFrom(ops)) {
case ADD:
assertEquals(reference.add(k), base.add(k));
break;
assertEquals(reference.remove(k), base.remove(k));
break;
assertEquals(reference.contains(k), base.contains(k));
break;
assertEquals(reference.isEmpty(), base.isEmpty());
break;
代码示例来源:origin: apache/kylin
private void closeReader(Reader r) throws IOException {
synchronized (lock) {
if (activeReaders.contains(r) == false)
throw new IllegalStateException();
activeReaders.remove(r);
if (activeReaders.isEmpty())
closeReadChannel();
}
}
代码示例来源:origin: com.h2database/h2
@Override
public void unlock(Session s) {
if (database != null) {
traceLock(s, lockExclusiveSession == s, "unlock");
if (lockExclusiveSession == s) {
lockExclusiveSession = null;
}
synchronized (database) {
if (!lockSharedSessions.isEmpty()) {
lockSharedSessions.remove(s);
}
if (!waitingSessions.isEmpty()) {
database.notifyAll();
}
}
}
}
代码示例来源:origin: naman14/Timber
uniqueIds.add(ids[0]);
selection.append(ids[0]);
if (uniqueIds.add(ids[i])) {
uniqueIds.remove(id);
} while (topSongsCursor.moveToNext());
sortedList[idx++] = iter.next();
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Object removeEntity(EntityKey key) {
final Object entity = entitiesByKey.remove( key );
final Iterator itr = entitiesByUniqueKey.values().iterator();
while ( itr.hasNext() ) {
if ( itr.next() == entity ) {
itr.remove();
}
}
// Clear all parent cache
parentsByChild.clear();
entitySnapshotsByKey.remove( key );
nullifiableEntityKeys.remove( key );
if( batchFetchQueue != null ) {
getBatchFetchQueue().removeBatchLoadableEntityKey(key);
getBatchFetchQueue().removeSubselect(key);
}
return entity;
}
代码示例来源:origin: Sable/soot
if (t instanceof AnySubType) {
HashSet<SootClass> s = new HashSet<SootClass>();
s.add(declaringClass);
while (!s.isEmpty()) {
SootClass c = s.iterator().next();
s.remove(c);
if (!c.isInterface() && !c.isAbstract() && canStoreClass(c, declaringClass)) {
SootMethod concreteM = resolveConcreteDispatch(c, m);
代码示例来源:origin: apache/storm
Iterator<TopoProfileAction> iter = mod.iterator();
while (iter.hasNext()) {
TopoProfileAction action = iter.next();
if (!action.topoId.equals(dynamicState.currentAssignment.get_topology_id())) {
iter.remove();
if (modPending.contains(action)) {
boolean isTimeForStop = Time.currentTimeMillis() > action.request.get_time_stamp();
if (isTimeForStop) {
LOG.debug("Stopped {} action finished", action);
iter.remove();
modPending.remove(action);
} else {
LOG.warn("Stopping {} failed, will be retried", action);
modPending.add(action);
LOG.debug("Started {} now: {}", action, Time.currentTimeMillis());
} else {
代码示例来源:origin: apache/zookeeper
candidates.remove(self.getId()); // if we're here, I shouldn't be the leader
long curCandidate = candidates.iterator().next();
Proposal p = outstandingProposals.get(curZxid);
while (p!=null && !candidates.isEmpty()) {
for (Proposal.QuorumVerifierAcksetPair qvAckset: p.qvAcksetPairs){
if (candidates.isEmpty()) return curCandidate;
curCandidate = candidates.iterator().next();
if (candidates.size() == 1) return curCandidate;
内容来源于网络,如有侵权,请联系作者删除!