本文整理匯總了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();
}
}
};
}