本文整理汇总了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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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());
}
}
示例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]));
}
}
}
}
};
}
示例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;
}
示例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);
}
}
}