當前位置: 首頁>>代碼示例>>Java>>正文


Java HashSet.removeAll方法代碼示例

本文整理匯總了Java中java.util.HashSet.removeAll方法的典型用法代碼示例。如果您正苦於以下問題:Java HashSet.removeAll方法的具體用法?Java HashSet.removeAll怎麽用?Java HashSet.removeAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.HashSet的用法示例。


在下文中一共展示了HashSet.removeAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isContentFarm

import java.util.HashSet; //導入方法依賴的package包/類
private boolean isContentFarm(String domain) {
	String[] whitelistArray = settings.getString("pref_whitelist", "").split("\\r\\n|\\n|\\r");
	String[] blacklistArray = settings.getString("pref_blacklist", "").split("\\r\\n|\\n|\\r");

	HashSet<String> defaultSet = new HashSet<>(Arrays.asList(contentFarmDomainArray));

	if (blacklistArray.length > 0) {
		defaultSet.addAll(Arrays.asList(blacklistArray));
	}

	if (whitelistArray.length > 0) {
		defaultSet.removeAll(Arrays.asList(whitelistArray));
	}

	return defaultSet.contains(domain);
}
 
開發者ID:collaction,項目名稱:content-farm-blocker-android,代碼行數:17,代碼來源:DetectorActivity.java

示例2: deleteFromLocal

import java.util.HashSet; //導入方法依賴的package包/類
private void deleteFromLocal(OModel model, HashSet<Integer> checkIds, SyncResult syncResult) {
    ODomain domain = new ODomain();
    domain.add("id", "in", new ArrayList<>(checkIds));
    OdooResult result = odoo.searchRead(model.getModelName(), new OdooFields("id"), domain, 0, 0, null);
    if (result == null) {
        Log.e(TAG, "FATAL : Request aborted.");
        return;
    }
    if (result.containsKey("error")) {
        Log.e(TAG, result.get("error") + "");
        return;
    }
    HashSet<Integer> serverIds = new HashSet<>();
    for (OdooRecord record : result.getRecords()) {
        serverIds.add(record.getDouble("id").intValue());
    }
    checkIds.removeAll(serverIds);
    int deleted = model.deleteAll(new ArrayList<>(checkIds));
    if (syncResult != null) syncResult.stats.numDeletes += deleted;
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:21,代碼來源:SyncAdapter.java

示例3: delProvider

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * 刪除服務節點,要求備份
 *
 * @param config the config
 * @param delProviders the del providers
 */
protected void delProvider(ConsumerConfig config, List<Provider> delProviders){
    String key = FileRegistryHelper.buildKey(config);
    List<Provider> olds = memoryCache.get(key);
    if (olds != null) {
        HashSet<Provider> set = new HashSet<Provider>(olds);
        set.removeAll(delProviders);
        memoryCache.put(key, new ArrayList<Provider>(set));
    } else {
        memoryCache.put(key, delProviders);
    }
    // 備份到文件 改為定時寫
    needBackup = true;
    if(subscribe){
        ProviderListener listener = notifyListeners.get(key);
        if (listener != null) {
            listener.removeProvider(delProviders);
        }
    }
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:26,代碼來源:FileRegistry.java

示例4: onFactionChat

import java.util.HashSet; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onFactionChat(FactionChatEvent event)
{
  Player player = event.getPlayer();
  Faction faction = event.getFaction();
  String format = ChatColor.GOLD + "[" + ChatColor.RED + event.getChatChannel().getDisplayName() + ": " + ChatColor.YELLOW + faction.getName() + ChatColor.GOLD + "] " + ChatColor.GRAY + event.getFactionMember().getRole().getAstrix() + player.getName() + ": " + ChatColor.YELLOW + event.getMessage();
  HashSet<Player> recipients = new HashSet();
  recipients.removeAll(event.getRecipients());
  for (CommandSender recipient : recipients) {
    if ((recipient instanceof Player))
    {
      Player target = (Player)recipient;
      FactionUser user = event.isAsynchronous() ? this.plugin.getUserManager().getUserAsync(target.getUniqueId()) : this.plugin.getUserManager().getUser(player.getUniqueId());
      Collection<UUID> spying = user.getFactionChatSpying();
      if ((spying.contains(ALL_UUID)) || (spying.contains(faction.getUniqueID()))) {
        recipient.sendMessage(format);
      }
    }
  }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:21,代碼來源:FactionChatSpyArgument.java

示例5: includeFields

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Include certain fields for output
 * the included fields will be available for output, while other fields will not
 *
 * @param fieldKeys the names of fields to include
 */
public void includeFields(String... fieldKeys) {
    HashSet<String> fieldKeysToRemove = new HashSet<>();
    fieldKeysToRemove.addAll(this.itemMap.keySet());
    fieldKeysToRemove.removeAll(Arrays.asList(fieldKeys));
    this.itemMap.keySet().removeAll(fieldKeysToRemove);
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:13,代碼來源:Item.java

示例6: assertExactMatch

import java.util.HashSet; //導入方法依賴的package包/類
private void assertExactMatch(Set<String> set, String [] values) {
    HashSet<String> s = new HashSet<>();
    s.addAll(set);

    s.removeAll(Arrays.asList(values));
    if (s.size() != 0) {
        Assert.assertTrue("Content of set " + set + " does not match with provided array " + Arrays.asList(values), false);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:10,代碼來源:DAGraphTests.java

示例7: findNextNode

import java.util.HashSet; //導入方法依賴的package包/類
private static InternalDistributedMember findNextNode(
    Set<Map.Entry<InternalDistributedMember, HashSet<Integer>>> entrySet,
    HashSet<Integer> currentBucketSet) {

  InternalDistributedMember node = null;
  int max = -1;
  ArrayList<InternalDistributedMember> nodesOfEqualSize =
      new ArrayList<InternalDistributedMember>();
  for (Map.Entry<InternalDistributedMember, HashSet<Integer>> entry : entrySet) {
    HashSet<Integer> buckets = new HashSet<Integer>();
    buckets.addAll(entry.getValue());
    buckets.removeAll(currentBucketSet);

    if (max < buckets.size()) {
      max = buckets.size();
      node = entry.getKey();
      nodesOfEqualSize.clear();
      nodesOfEqualSize.add(node);
    } else if (max == buckets.size()) {
      nodesOfEqualSize.add(node);
    }
  }

  // return node;
  return (nodesOfEqualSize.size() > 0
      ? nodesOfEqualSize.get(PartitionedRegion.rand.nextInt(nodesOfEqualSize.size())) : null);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:28,代碼來源:FunctionExecutionNodePruner.java

示例8: findNextServer

import java.util.HashSet; //導入方法依賴的package包/類
private ServerLocation findNextServer(Set<Map.Entry<ServerLocation, HashSet<Integer>>> entrySet,
    HashSet<Integer> currentBucketSet) {

  ServerLocation server = null;
  int max = -1;
  ArrayList<ServerLocation> nodesOfEqualSize = new ArrayList<ServerLocation>();
  for (Map.Entry<ServerLocation, HashSet<Integer>> entry : entrySet) {
    HashSet<Integer> buckets = new HashSet<Integer>();
    buckets.addAll(entry.getValue());
    buckets.removeAll(currentBucketSet);

    if (max < buckets.size()) {
      max = buckets.size();
      server = entry.getKey();
      nodesOfEqualSize.clear();
      nodesOfEqualSize.add(server);
    } else if (max == buckets.size()) {
      nodesOfEqualSize.add(server);
    }
  }

  // return node;
  Random r = new Random();
  if (nodesOfEqualSize.size() > 0) {
    return nodesOfEqualSize.get(r.nextInt(nodesOfEqualSize.size()));
  }

  return null;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:30,代碼來源:ClientMetadataService.java

示例9: checkForInitialSet

import java.util.HashSet; //導入方法依賴的package包/類
private void checkForInitialSet(int i, ConcurrentMap testMap, Map initialSet) {
  HashSet found = new HashSet(testMap.values());
  if (!found.containsAll(initialSet.values())) {
    HashSet missed = new HashSet(initialSet.values());
    missed.removeAll(found);
    fail("On run " + i + " did not find these elements of the initial set using the iterator "
        + missed);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:10,代碼來源:ConcurrentHashMapIteratorJUnitTest.java

示例10: difference

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * @see org.odmg.DSet#difference(DSet)
 */
public DSet difference(DSet otherSet) {
	//TODO: perhaps not correct semantics - is it supposed to be symmetric?
	read();
	HashSet newset = new HashSet( this.set.size() );
	newset.addAll(this.set);
	newset.removeAll(otherSet);
	return new Set(getSession(), newset);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:12,代碼來源:Set.java

示例11: makeDiffMap1

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Reduces Map1 and its elements to the ones which did not occur in Map2.
 * 
 * @param Map1
 * @param Map2
 */
private static void makeDiffMap1(HashMap<String, HashSet<String>> Map1,
		HashMap<String, HashSet<String>> Map2) {
	Set<String> keySet1 = new HashSet(Map1.keySet()); // conversion is type
														// safe
	Set<String> keySet2 = new HashSet(Map2.keySet()); // conversion is type
														// safe
	for (String s : keySet1) {
		HashSet<String> values1 = Map1.get(s);
		HashSet<String> values2 = null;
		try {
			values2 = (HashSet<String>) Map2.get(s).clone(); // conversion
																// is type
																// safe
		} catch (NullPointerException e) {
			continue; // here a method was found which is new and did not
						// occur in map1
		}

		if ((values1 == null) || (values2 == null)) { // values should not
														// be both null
														// since only the
														// intersection is
														// considered
			throw new Error("Values are not both not null.");
		}
		values1.removeAll(values2);
		if (values1.isEmpty()) {
			Map1.remove(s);
		}
	}
}
 
開發者ID:bjrnmath,項目名稱:mutaflow,代碼行數:38,代碼來源:Parser.java

示例12: addSectionCounters

import java.util.HashSet; //導入方法依賴的package包/類
private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
    HashSet<Block> blocks = new HashSet<>(sectionBlocks);
    for (Loop<?> loop : childLoops) {
        blocks.removeAll(loop.getBlocks());
    }
    double weight = getSectionWeight(schedule, blocks) / cfg.blockFor(start).probability();
    DynamicCounterNode.addCounterBefore(GROUP_NAME, sectionHead(start), (long) weight, true, start.next());
    if (WITH_INVOKE_FREE_SECTIONS && !hasInvoke(blocks)) {
        DynamicCounterNode.addCounterBefore(GROUP_NAME_WITHOUT, sectionHead(start), (long) weight, true, start.next());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:ProfileCompiledMethodsPhase.java

示例13: MavenWhiteListQueryImpl

import java.util.HashSet; //導入方法依賴的package包/類
public MavenWhiteListQueryImpl(Project prj) {
    project = prj;
    projectListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            //TODO listen just on changes of classpath??
            if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
                synchronized (LOCK) {
                    Set<String> oldPrivate = cachePrivatePackages != null ? cachePrivatePackages.get() : null;
                    if (oldPrivate == null) {
                        oldPrivate = Collections.emptySet();
                    }
                    Set<String> oldTransitive = cacheTransitivePackages != null ? cacheTransitivePackages.get() : null;
                    if (oldTransitive == null) {
                        oldTransitive = Collections.emptySet();
                    }
                    isCached = false;
                    cacheOrLoad();
                    Set<String> newPrivate = cachePrivatePackages != null ? cachePrivatePackages.get() : null;
                    if (newPrivate == null) {
                        newPrivate = Collections.emptySet();
                    }
                    Set<String> newTransitive = cacheTransitivePackages != null ? cacheTransitivePackages.get() : null;
                    if (newTransitive == null) {
                        newTransitive = Collections.emptySet();
                    }
                    HashSet oldNotNew1 = new HashSet(oldPrivate);
                    oldNotNew1.removeAll(newPrivate);
                    HashSet newNotOld1 = new HashSet(newPrivate);
                    newNotOld1.removeAll(oldPrivate);
                    HashSet oldNotNew2 = new HashSet(oldTransitive);
                    oldNotNew2.removeAll(newTransitive);
                    HashSet newNotOld2 = new HashSet(newTransitive);
                    newNotOld2.removeAll(oldTransitive);
                    
                    boolean privateChanged = !oldNotNew1.isEmpty() || !newNotOld1.isEmpty();
                    boolean transitiveChanged = !oldNotNew2.isEmpty() || !newNotOld2.isEmpty();
                    if (privateChanged || transitiveChanged) {
                        ClassPath[] cps = project.getLookup().lookup(ProjectSourcesClassPathProvider.class).getProjectClassPaths(ClassPath.SOURCE);
                        Set<FileObject> fos = new HashSet<FileObject>();
                        for (ClassPath cp : cps) {
                            fos.addAll(Arrays.asList(cp.getRoots()));
                        }
                        LOG.log(Level.INFO, "Refreshing indexes for {0} because {1}{2} changed.", new Object[]{project.getProjectDirectory(), privateChanged ? "accessible private packages, " : "", transitiveChanged ? "accessible transitive packages " : ""});
                        LOG.log(Level.FINE, "changes in private1-{0}", Arrays.toString(oldNotNew1.toArray()));
                        LOG.log(Level.FINE, "changes in private2-{0}", Arrays.toString(newNotOld1.toArray()));
                        LOG.log(Level.FINE, "changes in transitive1-{0}", Arrays.toString(oldNotNew2.toArray()));
                        LOG.log(Level.FINE, "changes in transitive2-{0}", Arrays.toString(newNotOld2.toArray()));
                        IndexingManager.getDefault().refreshAllIndices(fos.toArray(new FileObject[0]));
                    }
                }
            }
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:57,代碼來源:MavenWhiteListQueryImpl.java

示例14: mergeExclusive

import java.util.HashSet; //導入方法依賴的package包/類
public static Collection<? extends Component> mergeExclusive(Collection<? extends Component> toMerge) {
	if (toMerge.size() <= 1)
		return toMerge;

	HashSet<Component> ret = new HashSet<Component>(toMerge);
	CircuitPoints points = computeCircuitPoints(toMerge);

	HashSet<Wire> wires = new HashSet<Wire>();
	for (Location loc : points.getSplitLocations()) {
		Collection<? extends Component> at = points.getComponents(loc);
		if (at.size() == 2) {
			Iterator<? extends Component> atIt = at.iterator();
			Component o0 = atIt.next();
			Component o1 = atIt.next();
			if (o0 instanceof Wire && o1 instanceof Wire) {
				Wire w0 = (Wire) o0;
				Wire w1 = (Wire) o1;
				if (w0.is_x_equal == w1.is_x_equal) {
					wires.add(w0);
					wires.add(w1);
				}
			}
		}
	}
	points = null;

	ret.removeAll(wires);
	while (!wires.isEmpty()) {
		Iterator<Wire> it = wires.iterator();
		Wire w = it.next();
		Location e0 = w.e0;
		Location e1 = w.e1;
		it.remove();
		boolean found;
		do {
			found = false;
			for (it = wires.iterator(); it.hasNext();) {
				Wire cand = it.next();
				if (cand.e0.equals(e1)) {
					e1 = cand.e1;
					found = true;
					it.remove();
				} else if (cand.e1.equals(e0)) {
					e0 = cand.e0;
					found = true;
					it.remove();
				}
			}
		} while (found);
		ret.add(Wire.create(e0, e1));
	}

	return ret;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:55,代碼來源:WireUtil.java

示例15: run

import java.util.HashSet; //導入方法依賴的package包/類
public void run() {
    HashSet<ChunkCoord> loadedChunksForProcess = new HashSet<ChunkCoord>();
    HashSet<ChunkCoord> unloadedChunksForProcess = new HashSet<ChunkCoord>();
    Map<World, HashSet<ChunkCoord>> chunksForReload = new WeakHashMap<World, HashSet<ChunkCoord>>();
    ArrayList<World> localWorldsToCheck = new ArrayList<World>();
    ArrayList<ChunkCoord> reloadedChunks = new ArrayList<ChunkCoord>();

    while (!this.isInterrupted() && !kill.get()) {
        try {
            // Wait until necessary
            long timeWait = lastExecute + OrebfuscatorConfig.ChunkReloaderRate - System.currentTimeMillis();
            lastExecute = System.currentTimeMillis();
            if (timeWait > 0) {
                Thread.sleep(timeWait);
            }

            synchronized (loadedChunks) {
                localWorldsToCheck.addAll(loadedChunks.keySet());
            }

            for(World world : localWorldsToCheck) {
                HashSet<ChunkCoord> chunksForReloadForWorld = chunksForReload.get(world);
                if(chunksForReloadForWorld == null) {
                    chunksForReload.put(world, chunksForReloadForWorld = new HashSet<ChunkCoord>());
                }

                synchronized (unloadedChunks) {
                    HashSet<ChunkCoord> unloadedChunksForWorld = unloadedChunks.get(world);

                    if(unloadedChunksForWorld != null && !unloadedChunksForWorld.isEmpty()) {
                        unloadedChunksForProcess.addAll(unloadedChunksForWorld);
                        unloadedChunksForWorld.clear();
                    }
                }

                for(ChunkCoord unloadedChunk : unloadedChunksForProcess) {
                    chunksForReloadForWorld.remove(unloadedChunk);
                }

                unloadedChunksForProcess.clear();

                synchronized (loadedChunks) {
                    HashSet<ChunkCoord> loadedChunksForWorld = loadedChunks.get(world);

                    if(loadedChunksForWorld != null && !loadedChunksForWorld.isEmpty()) {
                        loadedChunksForProcess.addAll(loadedChunksForWorld);
                        loadedChunksForWorld.clear();
                    }
                }

                for(ChunkCoord loadedChunk : loadedChunksForProcess) {
                    ChunkCoord chunk1 = new ChunkCoord(loadedChunk.x - 1, loadedChunk.z);
                    ChunkCoord chunk2 = new ChunkCoord(loadedChunk.x + 1, loadedChunk.z);
                    ChunkCoord chunk3 = new ChunkCoord(loadedChunk.x, loadedChunk.z - 1);
                    ChunkCoord chunk4 = new ChunkCoord(loadedChunk.x, loadedChunk.z + 1);

                    chunksForReloadForWorld.add(chunk1);
                    chunksForReloadForWorld.add(chunk2);
                    chunksForReloadForWorld.add(chunk3);
                    chunksForReloadForWorld.add(chunk4);
                }

                loadedChunksForProcess.clear();

                if(!chunksForReloadForWorld.isEmpty()) {
                    reloadChunks(world, chunksForReloadForWorld, reloadedChunks);

                    chunksForReloadForWorld.removeAll(reloadedChunks);
                    reloadedChunks.clear();
                }
            }

            localWorldsToCheck.clear();
        } catch (Exception e) {
            Orebfuscator.log(e);
        }
    }
}
 
開發者ID:SamaGames,項目名稱:AntiCheat,代碼行數:79,代碼來源:ChunkReloader.java


注:本文中的java.util.HashSet.removeAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。