List of usage examples for java.util Set removeAll
boolean removeAll(Collection<?> c);
From source file:com.techcavern.pircbotz.UserChannelDao.java
@Synchronized("accessLock") public ImmutableSortedSet<U> getNormalUsers(C channel) { Set<U> remainingUsers = new HashSet<U>(mainMap.getUsers(channel)); for (UserChannelMap<U, C> curLevelMap : levelsMap.values()) remainingUsers.removeAll(curLevelMap.getUsers(channel)); return ImmutableSortedSet.copyOf(remainingUsers); }
From source file:com.techcavern.pircbotz.UserChannelDao.java
@Synchronized("accessLock") public ImmutableSortedSet<C> getNormalUserChannels(U user) { Set<C> remainingChannels = new HashSet<C>(mainMap.getChannels(user)); for (UserChannelMap<U, C> curLevelMap : levelsMap.values()) remainingChannels.removeAll(curLevelMap.getChannels(user)); return ImmutableSortedSet.copyOf(remainingChannels); }
From source file:mydropbox.Client.java
public void checkForChanges() throws IOException { long timestamp_current = getTimeStamp(); long timestamp_cloud = askForTimeStamp(); long timestampToSave; Set<String> fileList_cloud = new HashSet<String>(); Set<String> fileList_local = new HashSet<String>(); if (timestamp_current != timestamp_cloud) { timestampToSave = Long.max(timestamp_cloud, timestamp_current); fileList_cloud = askForFileList(); File folder = new File("./files/"); File[] listOfFiles = folder.listFiles(); for (File f : listOfFiles) { if (f.isFile()) { fileList_local.add(f.getName()); }//from w ww . j a v a 2 s . co m } if (timestamp_current < timestamp_cloud) { System.out.println("Cloud is ahead"); //Files that need to be removed Set<String> toRemoveList = new HashSet<String>(); toRemoveList.addAll(fileList_local); toRemoveList.removeAll(fileList_cloud); //Files that need to be downloaded Set<String> toTransferList = new HashSet<String>(); toTransferList.addAll(fileList_cloud); toTransferList.removeAll(fileList_local); try { File file; for (String f : toRemoveList) { file = new File("./files/" + f); file.delete(); } for (String f : toTransferList) { downloadFile(f); } } catch (Exception e) { e.printStackTrace(); } finally { setTimeStamp(timestampToSave); } } else { System.out.println("Client is ahead"); //Files that need to be removed in the cloud Set<String> toRemoveList = new HashSet<String>(); toRemoveList.addAll(fileList_cloud); toRemoveList.removeAll(fileList_local); //Files that need to be uploaded Set<String> toTransferList = new HashSet<String>(); toTransferList.addAll(fileList_local); toTransferList.removeAll(fileList_cloud); try { File file; for (String f : toRemoveList) { deleteFile(f); } for (String f : toTransferList) { sendFile(f); } } catch (Exception e) { e.printStackTrace(); } finally { setTimeStamp(timestampToSave); } } } }
From source file:cc.kave.commons.pointsto.analysis.inclusion.ConstraintGenerationVisitorContext.java
private void initializeMissingMembers(Set<IMemberName> constructorInitializedMembers) { // approximate the members which are directly initialized and initialize // them//from w w w . j av a2 s . c om Set<IMemberName> uninitializedMembers = new HashSet<>(declMapper.getAssignableMembers()); uninitializedMembers.removeAll(constructorInitializedMembers); for (IMemberName member : uninitializedMembers) { IMemberReference memberRef = null; if (member instanceof IFieldName) { memberRef = fieldReference((IFieldName) member); } else if (member instanceof IPropertyName) { IPropertyName property = (IPropertyName) member; if (treatPropertyAsField.test(property)) { memberRef = propertyReference(property); } } else if (member instanceof IEventName) { memberRef = eventReference((IEventName) member); } else { throw new UnexpectedNameException(member); } if (memberRef != null) { SetVariable temp = builder.createTemporaryVariable(); AllocationSite allocationSite = new UndefinedMemberAllocationSite(member, member.getValueType()); builder.allocate(temp, allocationSite); builder.writeMember(memberRef, temp, member); if (allocationSite.getType().isArray()) { // provide one array entry SetVariable arrayEntry = builder.createTemporaryVariable(); builder.allocate(arrayEntry, new ArrayEntryAllocationSite(allocationSite)); builder.writeArray(temp, arrayEntry); } } } }
From source file:com.xpn.xwiki.plugin.workspacesmanager.apps.DefaultWorkspaceApplicationManager.java
/** * {@inheritDoc}/* w w w. ja va2s. com*/ */ public Set<String> getAvailableApplicationsNames(String spaceName, XWikiContext context) throws WorkspacesManagerException { Set<String> availableApps = getAllWorkspacesApps(context); Set<String> installedApps = getApplicationsForSpace(spaceName, context).keySet(); availableApps.removeAll(installedApps); return availableApps; }
From source file:org.solmix.runtime.support.spring.SpringBeanProvider.java
/** * {@inheritDoc}/*from ww w .j a va2 s .c om*/ * * @see org.solmix.api.bean.ConfiguredBeanProvider#getBeanNamesOfType(java.lang.Class) */ @Override public List<String> getBeanNamesOfType(Class<?> type) { Set<String> s = new LinkedHashSet<String>(Arrays.asList(context.getBeanNamesForType(type, false, false))); if (context.getParent() != null) { s.addAll(doGetBeanNamesOfType0(context.getParent(), type)); } s.removeAll(passThroughs); if (original != null) { List<String> origs = original.getBeanNamesOfType(type); if (origs != null) s.addAll(original.getBeanNamesOfType(type)); } return new ArrayList<String>(s); }
From source file:fungus.JungObserver.java
public boolean execute() { MycoCast mycocast = (MycoCast) Network.get(0).getProtocol(mycocastPid); int bio = mycocast.countBiomass(); int bul = mycocast.countBulwark(); int ext = mycocast.countExtending(); int bra = mycocast.countBranching(); int imm = mycocast.countImmobile(); // Need to wipe existing graph (reimplement with some intelligence) //for (String v : graph.getVertices()) { // System.out.println("womble"); // graph.removeVertex(v); // }/*from w w w. j av a2s . c o m*/ // Update vertices Set<MycoNode> activeNodes = new HashSet<MycoNode>(); for (int i = 0; i < Network.size(); i++) { MycoNode n = (MycoNode) Network.get(i); activeNodes.add(n); HyphaData data = n.getHyphaData(); //if (data.isBiomass()) { continue; } if (graph.containsVertex(n)) { graph.removeVertex(n); } if (!graph.containsVertex(n)) { graph.addVertex(n); } } Set<MycoNode> visualizerNodes = new HashSet<MycoNode>(graph.getVertices()); visualizerNodes.removeAll(activeNodes); for (MycoNode n : visualizerNodes) { graph.removeVertex(n); } // Update edges for (int i = 0; i < Network.size(); i++) { MycoNode n = (MycoNode) Network.get(i); HyphaData data = n.getHyphaData(); HyphaLink link = n.getHyphaLink(); MycoList neighbors = link.getHyphae(); Collection<MycoNode> jungNeighbors = graph.getNeighbors(n); for (MycoNode o : jungNeighbors) { if (!neighbors.contains(o)) { String edge = graph.findEdge(n, o); if (edge != null) { graph.removeEdge(edge); } /*String edgeName; if (n.getID() < o.getID()) { edgeName = Long.toString(n.getID()) + "-" + Long.toString(o.getID()); } else { edgeName = Long.toString(o.getID()) + "-" + Long.toString(n.getID()); } graph.removeEdge(edgeName);*/ } } for (MycoNode o : neighbors) { String edgeName; edgeName = Long.toString(n.getID()) + "-" + Long.toString(o.getID()); if (!graph.containsEdge(edgeName)) { graph.addEdge(edgeName, n, o, EdgeType.DIRECTED); } /* String edgeName; if (n.getID() < o.getID()) { edgeName = Long.toString(n.getID()) + "-" + Long.toString(o.getID()); } else { edgeName = Long.toString(o.getID()) + "-" + Long.toString(n.getID()); } if (!graph.containsEdge(edgeName)) { graph.addEdge(edgeName, n, o, EdgeType.UNDIRECTED); }*/ } } visualizer.stateChanged(new ChangeEvent(graph)); try { while (stepBlocked && !noBlock) { synchronized (this) { wait(); } } } catch (InterruptedException e) { stepBlocked = true; } stepBlocked = true; //System.out.println(graph.toString()); return false; }
From source file:eu.esdihumboldt.util.scavenger.AbstractResourceScavenger.java
/** * @see ResourceScavenger#triggerScan()//from www .j ava 2s. c o m */ @Override public void triggerScan() { synchronized (resources) { if (huntingGrounds != null) { if (huntingGrounds.isDirectory()) { // scan for sub-directories Set<String> foundIds = new HashSet<String>(); File[] resourceDirs = huntingGrounds.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { // accept non-hidden directories return pathname.isDirectory() && !pathname.isHidden(); } }); for (File resourceDir : resourceDirs) { String resourceId = resourceDir.getName(); foundIds.add(resourceId); if (!resources.containsKey(resourceId)) { // resource reference not loaded yet T reference; try { reference = loadReference(resourceDir, null, resourceId); resources.put(resourceId, reference); onAdd(reference, resourceId); } catch (IOException e) { log.error("Error creating resource reference", e); } } else { // update existing resource updateResource(resources.get(resourceId), resourceId); } } Set<String> removed = new HashSet<String>(resources.keySet()); removed.removeAll(foundIds); // deal with resources that have been removed for (String resourceId : removed) { T reference = resources.remove(resourceId); if (reference != null) { // remove active environment onRemove(reference, resourceId); } } } else { // one project mode if (!resources.containsKey(DEFAULT_RESOURCE_ID)) { // project configuration not loaded yet T reference; try { reference = loadReference(huntingGrounds.getParentFile(), huntingGrounds.getName(), DEFAULT_RESOURCE_ID); resources.put(DEFAULT_RESOURCE_ID, reference); onAdd(reference, DEFAULT_RESOURCE_ID); } catch (IOException e) { log.error("Error creating project handler", e); } } else { // update existing project updateResource(resources.get(DEFAULT_RESOURCE_ID), DEFAULT_RESOURCE_ID); } } } } }
From source file:com.atolcd.alfresco.audit.web.scripts.NeverLoggedUsersGet.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { try {/*from w ww.ja v a 2 s. c om*/ List<Map<String, Object>> peopleConnectOnce = auditQueriesService.usersNeverLog(); Set<String> peopleAuthenticate = new HashSet<String>(); for (Map<String, Object> entry : peopleConnectOnce) peopleAuthenticate.add((String) entry.get("value")); Set<NodeRef> allPeople = personService.getAllPeople(); Set<String> allPeopleString = new HashSet<String>(); for (NodeRef people : allPeople) allPeopleString.add((String) nodeService.getProperty(people, ContentModel.PROP_USERNAME)); // Add guest user, authentication/authenticate don't generate audit // result for guest user. peopleAuthenticate.add(AuthenticationUtil.getGuestUserName()); allPeopleString.removeAll(peopleAuthenticate); Map<String, Object> model = new HashMap<String, Object>(); model.put("NeverLoggedUsers", allPeopleString); return model; } catch (Exception e) { throw new WebScriptException("[NeverLoggedUsersGet] Error in executeImpl function"); } }
From source file:io.druid.segment.IndexMaker.java
private static void makeIndexBinary(final FileSmoosher v9Smoosher, final List<IndexableAdapter> adapters, final File outDir, final List<String> mergedDimensions, final List<String> mergedMetrics, final Set<String> skippedDimensions, final ProgressIndicator progress, final IndexSpec indexSpec) throws IOException { final String section = "building index.drd"; progress.startSection(section);//from w w w .j a va2 s .co m final Set<String> finalColumns = Sets.newTreeSet(); finalColumns.addAll(mergedDimensions); finalColumns.addAll(mergedMetrics); finalColumns.removeAll(skippedDimensions); final Iterable<String> finalDimensions = Iterables.filter(mergedDimensions, new Predicate<String>() { @Override public boolean apply(String input) { return !skippedDimensions.contains(input); } }); GenericIndexed<String> cols = GenericIndexed.fromIterable(finalColumns, GenericIndexed.STRING_STRATEGY); GenericIndexed<String> dims = GenericIndexed.fromIterable(finalDimensions, GenericIndexed.STRING_STRATEGY); final String bitmapSerdeFactoryType = mapper.writeValueAsString(indexSpec.getBitmapSerdeFactory()); final long numBytes = cols.getSerializedSize() + dims.getSerializedSize() + 16 + serializerUtils.getSerializedStringByteSize(bitmapSerdeFactoryType); final SmooshedWriter writer = v9Smoosher.addWithSmooshedWriter("index.drd", numBytes); cols.writeToChannel(writer); dims.writeToChannel(writer); DateTime minTime = new DateTime(JodaUtils.MAX_INSTANT); DateTime maxTime = new DateTime(JodaUtils.MIN_INSTANT); for (IndexableAdapter index : adapters) { minTime = JodaUtils.minDateTime(minTime, index.getDataInterval().getStart()); maxTime = JodaUtils.maxDateTime(maxTime, index.getDataInterval().getEnd()); } final Interval dataInterval = new Interval(minTime, maxTime); serializerUtils.writeLong(writer, dataInterval.getStartMillis()); serializerUtils.writeLong(writer, dataInterval.getEndMillis()); serializerUtils.writeString(writer, bitmapSerdeFactoryType); writer.close(); IndexIO.checkFileSize(new File(outDir, "index.drd")); progress.stopSection(section); }