本文整理汇总了Java中java.util.TreeSet.retainAll方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSet.retainAll方法的具体用法?Java TreeSet.retainAll怎么用?Java TreeSet.retainAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.TreeSet
的用法示例。
在下文中一共展示了TreeSet.retainAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRetainAll
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* retainAll(c) retains only those elements of c and reports true if changed
*/
public void testRetainAll() {
TreeSet q = populatedSet(SIZE);
TreeSet p = populatedSet(SIZE);
for (int i = 0; i < SIZE; ++i) {
boolean changed = q.retainAll(p);
if (i == 0)
assertFalse(changed);
else
assertTrue(changed);
assertTrue(q.containsAll(p));
assertEquals(SIZE - i, q.size());
p.pollFirst();
}
}
示例2: getOverlappedClasses
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* Gets the overlapped classes for the given subnetworks.
* @param subnet1 The first subnetwork of stations.
* @param subnet2 The second subnetwork of stations.
* @return The set of overlapped classes.
*/
@SuppressWarnings("unused")
private TreeSet<Integer> getOverlappedClasses(TreeSet<Integer> subnet1, TreeSet<Integer> subnet2) {
TreeSet<Integer> c1 = getCoveredClasses(Covered.PARTIALLY, subnet1);
TreeSet<Integer> c2 = getCoveredClasses(Covered.PARTIALLY, subnet2);
c1.retainAll(c2);
return c1;
}
示例3: stdConvolution
import java.util.TreeSet; //导入方法依赖的package包/类
/**
* Computes g-arrays at a node using using the standard
* convolution equation(equ (4) from the LamLien83 paper).
* @param parentNode The node to compute the g-array for.
* @param parentPcPops The parent populations for partially covered classes.
* @param popVec The max population vector to use in the calculation.
* @param backup Whether to store the results in a backup g-array map.
*/
private void stdConvolution(Node parentNode, PopulationVector p, PopulationVector popVec, boolean backup) {
PopulationVector origp = p.copy();
PopulationVector origPopVec = popVec.copy();
Node leftChild = parentNode.leftChild();
Node rightChild = parentNode.rightChild();
PopulationVector iminusj;
// Find the intersection of partially covered classes in the child nodes.
TreeSet<Integer> commonPcs = new TreeSet<Integer>(leftChild.pcs);
commonPcs.retainAll(rightChild.pcs);
while (p != null) {
// Set the max values in popVec to same as parent population
// vector for corresponding partially covered classes.
int x = 0;
for (int pc : parentNode.pcs) {
popVec.set(pc, p.get(x));
x++;
}
// Get the maximum population for each partially covered class in commonPcs.
PopulationVector commonPopVec = ccu.contract(popVec, ccu.all, commonPcs);
PopulationVector maxes = commonPopVec.copy();
BigDecimal res = BigDecimal.ZERO;
while (commonPopVec != null) {
// Do subtraction only on common partially covered class populations.
iminusj = maxes.subVec(commonPopVec);
// Expand population vector to necessary size depending on child partially covered classes.
PopulationVector jFull = ccu.expand(commonPopVec, commonPcs, popVec, leftChild.pcs);
PopulationVector iminusjFull = ccu.expand(iminusj, commonPcs, popVec, rightChild.pcs);
BigDecimal l, r;
if (backup) {
l = (leftChild.backupContains(origPopVec))
? leftChild.getBackupGarr(origPopVec, jFull) : leftChild.getGarr(jFull);
r = (rightChild.backupContains(origPopVec))
? rightChild.getBackupGarr(origPopVec, iminusjFull) : rightChild.getGarr(iminusjFull);
} else {
l = leftChild.getGarr(jFull);
r = rightChild.getGarr(iminusjFull);
}
if (l == null || r == null) {
commonPopVec = ccu.nextPermutation(commonPopVec, maxes);
continue;
}
res = res.add(l.multiply(r, Config.Context));
commonPopVec = ccu.nextPermutation(commonPopVec, maxes);
}
parentNode.store(origPopVec, p, res, backup);
Printer.out.println(p.toString() + " : " + res);
p = ccu.nextPermutation(p, origp);
}
}
示例4: childrenOverlappedPcsHaveLargePopulation
import java.util.TreeSet; //导入方法依赖的package包/类
/** Checks whether this node's children have a large population overlap in their partially covered classes.
* This is defined to be true if the overlap is greater than the FEEDBACK_FILTERING_OVERLAP_POP_THRESHOLD
* constant defined in Config.
* @param popVec The full population vector.
* @return A boolean indicating whether the population overlap is large.
*/
public boolean childrenOverlappedPcsHaveLargePopulation(PopulationVector popVec) {
TreeSet<Integer> overlapped = new TreeSet<Integer>(leftChild.pcs);
overlapped.retainAll(rightChild.pcs);
for (int cls : leftChild.pcs) {
if (overlapped.contains(cls) && popVec.get(cls) > Config.FEEDBACK_FILTERING_OVERLAP_POP_THRESHOLD) {
return true;
}
}
return false;
}
示例5: retainAll
import java.util.TreeSet; //导入方法依赖的package包/类
public boolean retainAll(Collection<?> c)
{
for(TreeSet<E> target : other)
{
target.retainAll(c);
}
return super.retainAll(c);
}
示例6: init
import java.util.TreeSet; //导入方法依赖的package包/类
@Override
public void init(IWorkbench targetWorkbench, IStructuredSelection currentSelection) {
// this.selection = currentSelection;
List<?> selectedResources = IDE.computeSelectedResources(currentSelection);
List<IProject> workspaceProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
// Find all selected projects
Set<IProject> projects = selectedResources.stream()
.filter(m -> m instanceof IResource)
.map(m -> ((IResource) m).getProject())
.filter(p -> p.isOpen()) // only open projects
.collect(Collectors.toSet());
// make the behavior predictable by ordering:
TreeSet<IProject> sortedProjects = Sets
.<IProject> newTreeSet((a, b) -> a.getName()
.compareToIgnoreCase(b.getName()));
sortedProjects.addAll(projects);
// 0) turn into IN4JSProject and give and process further.
// a) find out which projects fulfill the npm-"exportable"-contract
// b) give back a list to the user what to export,
// c) disable things not fullfilling the contract.
// d) take choosing from the list and pass to exporter in non-ui package.
// 0)
List<IN4JSEclipseProject> rawN4jsProjects = Lists.newArrayList();
iP2in4jsP = HashBiMap.create();
for (IProject iProject : workspaceProjects) {
IN4JSEclipseProject mappedIn4jsProject = map2In4js(iProject);
if (mappedIn4jsProject != null) {
rawN4jsProjects.add(mappedIn4jsProject);
iP2in4jsP.put(iProject, mappedIn4jsProject);
}
}
// filter out Non-N4JS-projects from initial selection.
sortedProjects.retainAll(iP2in4jsP.keySet());
// filter out all non-N4JS-projects from the workspace projects.
ArrayList<IProject> filteredWorkspaceProjects = new ArrayList<>(workspaceProjects);
filteredWorkspaceProjects.retainAll(iP2in4jsP.keySet());
setWindowTitle("N4JS to npm Export");
setNeedsProgressMonitor(true);
Map<IProject, Boolean> selectedProjects = new HashMap<>();
// Add all workspace projects to list, default selection value is false
filteredWorkspaceProjects.forEach(project -> selectedProjects.put(project, false));
// Override selection value for all initially selected projects
sortedProjects.forEach(project -> selectedProjects.put(project, true));
// exportPage = new ExportSelectionPage("Export Page", rawN4jsProjects, labelProvider);
exportPage = new ExportSelectionPage("Export Page", selectedProjects);
if (runTools())
toolRunnerPage = new NpmToolRunnerPage("npm Execution Page");
comparePage = new PackageJsonComparePage("Compare package.json Page");
pageListener = new IPageChangedListener() {
@Override
public void pageChanged(PageChangedEvent event) {
if (event.getSelectedPage() == comparePage) {
udpatePackagJasonComparison();
}
}
};
}