下面列出了java.util.Collection#removeAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressWarnings("unchecked")
public Collection<V> removeTargetVertices(Collection<V> vs) {
if (this.graph == null) return null;
if (vs==null) return null;
boolean result = false;
if (!this.graph.isMultiGraph()) {
Collection<V> vvs = new ArrayList<V>(this.target); vvs.removeAll(vs);
if (!this.checkEdge(this.source, vvs)) return null;
}
super.removeVertices(vs);
result = this.target.removeAll(vs);
this.graph.removeIndex(this, vs);
return result ? vs : null;
}
/**
* The argument for {@code remains} is updated on each call.
*/
private PlatformObject buildTreeRoot(
GraphModel master,
Collection<GraphNode> remains,
GraphEdgeMatcherDescriptor matcher) {
// Build the hierarchy for this set of nodes and matcher
GraphModel treeGraph = GraphBuilders.buildFromNodes(master, remains);
GraphData<GraphNode> data = GraphData.createGraphData(
NodeTreeProviders.GRAPH_NODE_PROVIDER,
treeGraph, matcher.getInfo());
// Update remains with info from hierarchy tree
TreeModel tree = data.getTreeModel();
remains.removeAll(tree.computeTreeNodes());
// provide the root viewing object
String label = MessageFormat.format("Tree of {0}", matcher.getName());
return new ActionTreeRoot(data, label, matcher);
}
/**
* Prunes matches/partial matches based on the chosen strategy.
*
* @param matchesToPrune current partial matches
* @param matchedResult already completed matches
* @param sharedBufferAccessor accessor to corresponding shared buffer
* @throws Exception thrown if could not access the state
*/
public void prune(
Collection<ComputationState> matchesToPrune,
Collection<Map<String, List<EventId>>> matchedResult,
SharedBufferAccessor<?> sharedBufferAccessor) throws Exception {
EventId pruningId = getPruningId(matchedResult);
if (pruningId != null) {
List<ComputationState> discardStates = new ArrayList<>();
for (ComputationState computationState : matchesToPrune) {
if (computationState.getStartEventID() != null &&
shouldPrune(computationState.getStartEventID(), pruningId)) {
sharedBufferAccessor.releaseNode(computationState.getPreviousBufferEntry());
discardStates.add(computationState);
}
}
matchesToPrune.removeAll(discardStates);
}
}
@SuppressWarnings("all")
protected boolean matchCreatorId(Object result, String userId) {
if (null == result) {
return true;
}
if (result instanceof RecordCreationEntity) {
return userId.equals(((RecordCreationEntity) result).getCreatorId());
} else if (result instanceof Collection) {
Collection<?> collection = ((Collection) result);
//删掉不能访问的对象
collection.removeAll(collection.stream().filter((Object o) -> !matchCreatorId(o, userId)).collect(Collectors.toList()));
} else {
try {
return userId.equals(PropertyUtils.getProperty(result, "creatorId"));
} catch (Exception ignore) {
}
}
return true;
}
protected void putAllAttributes(Map<String, Object> incomingData,
boolean completeReplace) {
getAttributeLock().writeLock().lock();
try {
for (Entry<String, Object> entry : incomingData.entrySet()) {
Object oldValue = data.put(entry.getKey(), entry.getValue());
if (!Objects.equals(oldValue, entry.getValue()))
firePropertyChangeListeners(entry.getKey(), oldValue,
entry.getValue());
}
if (completeReplace) {
Collection<String> z = new HashSet<>(data.keySet());
z.removeAll(incomingData.keySet());
for (String unusedKey : z) {
setAttribute(new Key<String>(String.class, unusedKey), null);
}
}
} finally {
getAttributeLock().writeLock().unlock();
}
}
public Collection<MCRAccessDefinition> getRules(String objid) {
try {
Collection<String> pools = MCRAccessStore.getInstance().getDatabasePools();
//merge pools
pools.removeAll(getPools());
pools.addAll(getPools());
Collection<MCRAccessDefinition> ret = new LinkedList<>();
//List elements = new LinkedList();
MCRAccessDefinition def = new MCRAccessDefinition();
def.setObjID(objid);
for (String pool : pools) {
String rule = getRuleID(objid, pool);
if (rule != null) {
def.addPool(pool, rule);
} else {
def.addPool(pool, " ");
}
}
ret.add(def);
return ret;
} catch (Exception e) {
LOGGER.error("definition loading failed: ");
return null;
}
}
public static void checkIngression(IngressionType ingressionType, Person person, DegreeCurricularPlan degreeCurricularPlan) {
if (ingressionType!=null && ingressionType.isReIngression()) {
if (person == null || person.getStudent() == null) {
throw new DomainException("error.registration.preBolonhaSourceDegreeNotFound");
}
if (degreeCurricularPlan.getEquivalencePlan() != null) {
final Student student = person.getStudent();
final Degree sourceDegree = degreeCurricularPlan.getEquivalencePlan().getSourceDegreeCurricularPlan().getDegree();
Registration sourceRegistration = person.getStudent().readRegistrationByDegree(sourceDegree);
if (sourceRegistration == null) {
final Collection<Registration> registrations =
student.getRegistrationsMatchingDegreeType(DegreeType::isPreBolonhaDegree);
registrations.removeAll(student.getRegistrationsFor(degreeCurricularPlan));
sourceRegistration = registrations.size() == 1 ? registrations.iterator().next() : null;
}
if (sourceRegistration == null) {
throw new DomainException("error.registration.preBolonhaSourceDegreeNotFound");
} else if (!sourceRegistration.getActiveStateType().canReingress()) {
throw new DomainException("error.registration.preBolonhaSourceRegistrationCannotReingress");
}
}
}
}
@Override
protected boolean updateWithNondominated(Collection<Individual> candidates) {
boolean changed = false;
if (this.size() + candidates.size() <= capacity) {
changed = addCheckedIndividuals(candidates);
} else {
candidates.addAll(this);
Crowding crowding = new Crowding();
List<Individual> list = crowding.order(crowding.getDensityValues(candidates));
List<Individual> worst = list.subList(capacity, list.size());
candidates.removeAll(worst);
this.retainAll(candidates);
for (Individual i : candidates) {
if (!this.contains(i)) {
changed |= addCheckedIndividual(i);
}
}
}
return changed;
}
/**
* Returns -1 if c1 is missing an element in c2, 1 if c2 is missing an element
* in c1, or 0 is they contain the exact same elements.
* @throws NullPointerException if either c1 or c2 is null
*/
private static int joint(Collection<?> c1, Collection<?> c2) {
if (c1.size() < c2.size()) {
return -1;
} else if (c2.size() < c1.size()) {
return 1;
}
Collection<Object> c3 = new ArrayList<Object>();
c3.addAll(c1);
c3.removeAll(c2);
if (c3.size() > 0) {
return -1;
}
c3.addAll(c2);
c3.removeAll(c1);
if (c3.size() > 0) {
return 1;
}
return 0;
}
@Override
public Collection<MutationDetails> intercept(
Collection<MutationDetails> mutations, Mutater m) {
final Map<Location,Collection<MutationDetails>> buckets = FCollection.bucket(mutations, mutationToLocation());
final List<MutationDetails> willTimeout = new ArrayList<>();
for (final Entry<Location, Collection<MutationDetails>> each : buckets.entrySet() ) {
willTimeout.addAll(findTimeoutMutants(each.getKey(), each.getValue(), m));
}
mutations.removeAll(willTimeout);
return mutations;
}
protected Collection<EPackage> getRegistryPackagesToValidate() {
Collection<EPackage> _xblockexpression = null;
{
final Collection<EPackage> packages = GrammarUtil.allEPackagesToValidate(this.grammar);
final Function1<GeneratedMetamodel, EPackage> _function = (GeneratedMetamodel it) -> {
return it.getEPackage();
};
packages.removeAll(
IterableExtensions.<EPackage>toList(IterableExtensions.<GeneratedMetamodel, EPackage>map(Iterables.<GeneratedMetamodel>filter(GrammarUtil.allMetamodelDeclarations(this.grammar), GeneratedMetamodel.class), _function)));
_xblockexpression = packages;
}
return _xblockexpression;
}
private void detectFractions() throws Exception {
final File tmpFile = File.createTempFile("buildtool", this.projectAsset.getName().replace("/", "_"));
tmpFile.deleteOnExit();
this.projectAsset.getArchive().as(ZipExporter.class).exportTo(tmpFile, true);
final FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer()
.logger(log)
.source(tmpFile);
if (testClass != null && !"".equals(testClass)) {
analyzer.testClass(testClass);
}
final Collection<FractionDescriptor> detectedFractions = analyzer.detectNeededFractions();
//don't overwrite fractions added by the user
detectedFractions.removeAll(this.fractions.stream()
.map(ArtifactSpec::toFractionDescriptor)
.collect(Collectors.toSet()));
// Remove explicitly excluded fractions
detectedFractions.removeAll(this.excludedFractions.stream().map(ArtifactSpec::toFractionDescriptor).collect(Collectors.toSet()));
this.log.info(String.format("Detected %sfractions: %s",
this.fractions.isEmpty() ? "" : "additional ",
detectedFractions.stream()
.map(FractionDescriptor::av)
.sorted()
.collect(Collectors.joining(", "))));
detectedFractions.stream()
.map(ArtifactSpec::fromFractionDescriptor)
.forEach(this::fraction);
}
/**
* Report the system that contains ALL glyphs provided.
* If all glyphs do not belong to the same system, exception is thrown
*
* @param glyphs the collection of glyphs
* @return the containing system
* @exception IllegalArgumentException raised if glyphs collection is not OK
*/
public SystemInfo getSystemOf (Collection<Glyph> glyphs)
{
if ((glyphs == null) || glyphs.isEmpty()) {
throw new IllegalArgumentException(
"getSystemOf. Glyphs collection is null or empty");
}
SystemInfo system = null;
Collection<Glyph> toRemove = new ArrayList<>();
for (Glyph glyph : glyphs) {
SystemInfo glyphSystem = glyph.isVirtual()
? getSystemOf(glyph.getAreaCenter())
: getSystemOf(glyph);
if (glyphSystem == null) {
toRemove.add(glyph);
} else {
if (system == null) {
system = glyphSystem;
} else {
// Make sure we are still in the same system
if (glyphSystem != system) {
throw new IllegalArgumentException(
"getSystemOf. Glyphs from different systems ("
+ getSystemOf(glyph) + " and " + system + ") "
+ Glyphs.toString(glyphs));
}
}
}
}
if (!toRemove.isEmpty()) {
logger.warn("No system for {}", Glyphs.toString(toRemove));
glyphs.removeAll(toRemove);
}
return system;
}
@Override
public Collection<K> getModifiedBeans() {
Collection<K> returnValue = new HashSet<>();
Object lock = acquireReadLock();
try {
returnValue.addAll(dataByBeanId.keySet());
returnValue.removeAll(getIgnorableBeans());
return returnValue;
} finally {
releaseLock(lock);
}
}
private Collection<Degree> removeDegreesWithNoVacancy(final Collection<Degree> result) {
for (final String degreeCode : NO_VACANCY_DEGREE_CODES) {
result.removeAll(Degree.readAllByDegreeCode(degreeCode));
}
return result;
}
/**
* Compute the buffer of a circulinear curve.<p>
* The algorithm is as follow:
* <ol>
* <li> split the curve into a set of curves without self-intersections
* <li> for each split curve, compute the contour of its buffer
* <li> split self-intersecting contours into set of disjoint contours
* <li> split all contour which intersect each other to disjoint contours
* <li> remove contours which are too close from the original curve
* <li> create a new domain with the final set of contours
* </ol>
*/
public CirculinearDomain2D computeBuffer(
CirculinearCurve2D curve, double dist) {
ArrayList<CirculinearContour2D> contours =
new ArrayList<CirculinearContour2D>();
// iterate on all continuous curves
for (CirculinearContinuousCurve2D cont : curve.continuousCurves()) {
// split the curve into a set of non self-intersecting curves
for (CirculinearContinuousCurve2D splitted :
CirculinearCurves2D.splitContinuousCurve(cont)) {
// compute the rings composing the simple curve buffer
contours.addAll(computeBufferSimpleCurve(splitted, dist));
}
}
// split contours which intersect each others
contours = new ArrayList<CirculinearContour2D>(
CirculinearCurves2D.splitIntersectingContours(contours));
// Remove contours that cross or that are too close from base curve
ArrayList<CirculinearContour2D> contours2 =
new ArrayList<CirculinearContour2D>(contours.size());
Collection<Point2D> intersects;
Collection<Point2D> vertices;
for (CirculinearContour2D contour : contours) {
// do not keep contours which cross original curve
intersects = CirculinearCurves2D.findIntersections(curve, contour);
// remove intersection points that are vertices of the reference curve
vertices = curve.singularPoints();
vertices = curve.vertices();
intersects.removeAll(vertices);
if (intersects.size() > 0)
continue;
// check that vertices of contour are not too close from original
// curve
double distCurves =
getDistanceCurveSingularPoints(curve, contour);
if(distCurves < dist-Shape2D.ACCURACY)
continue;
// keep the contours that meet the above conditions
contours2.add(contour);
}
// All the rings are created, we can now create a new domain with the
// set of rings
return new GenericCirculinearDomain2D(
CirculinearContourArray2D.create(contours2.toArray(new CirculinearContour2D[0])));
}
public static synchronized Locale[] getInstalledDictionariesLocales() {
Collection<Locale> hardcoded = new HashSet<Locale>();
Collection<Locale> maskedHardcoded = new HashSet<Locale>();
Collection<Locale> user = new HashSet<Locale>();
for (File dictDir : InstalledFileLocator.getDefault().locateAll("modules/dict", null, false)) {
File[] children = dictDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().startsWith("dictionary_");
}
});
if (children == null)
continue;
for (int cntr = 0; cntr < children.length; cntr++) {
String name = children[cntr].getName();
name = name.substring("dictionary_".length());
Collection<Locale> target;
if (name.endsWith("_hidden")) {
target = maskedHardcoded;
} else {
if (name.endsWith(".description")) {
target = hardcoded;
} else {
target = user;
}
}
int dot = name.indexOf('.');
if (dot != (-1))
name = name.substring(0, dot);
target.add(Utilities.name2Locale(name));
}
}
hardcoded.removeAll(maskedHardcoded);
hardcoded.addAll(user);
return hardcoded.toArray(new Locale[hardcoded.size()]);
}
private static <T> Collection<T> only(Collection<T> a, Collection<T> b) {
Collection<T> onlyA = new HashSet<>(a);
onlyA.removeAll(b);
return onlyA;
}
/**
* @param clo Wrapper of logger.
* @param topVer Topology version.
* @param discoCache Discovery cache.
* @param evtType Event type.
* @param evtNode Event node.
* @param srvNodesNum Server nodes number.
* @param clientNodesNum Client nodes number.
* @param totalCpus Total cpu number.
* @param heap Heap size.
* @param offheap Offheap size.
*/
private void topologySnapshotMessage(IgniteClosure<String, Void> clo, long topVer, DiscoCache discoCache,
int evtType, ClusterNode evtNode, int srvNodesNum, int clientNodesNum, int totalCpus, double heap,
double offheap) {
DiscoveryDataClusterState state = discoCache.state();
String summary = PREFIX + " [" +
(discoOrdered ? "ver=" + topVer + ", " : "") +
"locNode=" + U.id8(discoCache.localNode().id()) +
", servers=" + srvNodesNum +
", clients=" + clientNodesNum +
", state=" + (state.active() ? "ACTIVE" : "INACTIVE") +
", CPUs=" + totalCpus +
", offheap=" + offheap + "GB" +
", heap=" + heap + "GB]";
clo.apply(summary);
ClusterNode currCrd = discoCache.oldestServerNode();
if ((evtType == EventType.EVT_NODE_FAILED || evtType == EventType.EVT_NODE_LEFT) &&
currCrd != null && currCrd.order() > evtNode.order())
clo.apply("Coordinator changed [prev=" + evtNode + ", cur=" + currCrd + "]");
BaselineTopology blt = state.baselineTopology();
if (blt != null && discoCache.baselineNodes() != null) {
int bltSize = discoCache.baselineNodes().size();
int bltOnline = discoCache.aliveBaselineNodes().size();
int bltOffline = bltSize - bltOnline;
clo.apply(" ^-- Baseline [id=" + blt.id() + ", size=" + bltSize + ", online=" + bltOnline
+ ", offline=" + bltOffline + ']');
ClusterState targetState = ctx.config().getClusterStateOnStart();
if (targetState == null)
targetState = ctx.config().isAutoActivationEnabled() ? ACTIVE : INACTIVE;
if (!state.state().active() && targetState.active()) {
String offlineConsistentIds = "";
if (bltOffline > 0 && bltOffline <= 5) {
Collection<BaselineNode> offlineNodes = new HashSet<>(discoCache.baselineNodes());
offlineNodes.removeAll(discoCache.aliveBaselineNodes());
offlineConsistentIds = ' ' + F.nodeConsistentIds(offlineNodes).toString();
}
if (bltOffline == 0) {
if (evtType == EVT_NODE_JOINED && discoCache.baselineNode(evtNode))
clo.apply(" ^-- All baseline nodes are online, will start auto-activation");
}
else
clo.apply(" ^-- " + bltOffline + " nodes left for auto-activation" + offlineConsistentIds);
}
}
}
@Override
public void removeRolesFromUser(User user, Collection<Role> roles) {
Collection<Role> userRoles = this.userRoles.computeIfAbsent(user, u -> new ArrayList<>(server.getRoles(u)));
userRoles.removeAll(roles);
}