当前位置: 首页>>代码示例>>Java>>正文


Java ArrayList.retainAll方法代码示例

本文整理汇总了Java中java.util.ArrayList.retainAll方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.retainAll方法的具体用法?Java ArrayList.retainAll怎么用?Java ArrayList.retainAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.retainAll方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: editWorkingList

import java.util.ArrayList; //导入方法依赖的package包/类
private void editWorkingList() {
    String list = listComboBox.getSelectedItem().toString();
    if (list.equals(CLEAR_LIST)) {
        ((ListEditorModel<String>) workingList.getModel()).clear();
    } else {
        if (unionCB.isSelected()) {
            ((ListEditorModel<String>) workingList.getModel()).addAll(
                    new ArrayList<String>(MFMPlayLists.getInstance().getPlayList(list)));
        } else if (intersectionCB.isSelected()) {
            // Gotta be a more direct way of doing this
            Object[] elements = ((ListEditorModel<String>) workingList.getModel()).toArray();
            String[] strings = Arrays.copyOf(elements, elements.length, String[].class);
            ArrayList<String> currentList = new ArrayList<String>(Arrays.asList(strings));
            currentList.retainAll(new ArrayList<String>(MFMPlayLists.getInstance().getPlayList(list)));
            ((ListEditorModel<String>) workingList.getModel()).refreshList(currentList);
        } else if (exclusionCB.isSelected()) {
            ((ListEditorModel<String>) workingList.getModel()).removeAll(
                    new ArrayList<String>(MFMPlayLists.getInstance().getPlayList(list)));
        }
    }
    displayCurrentCount();
}
 
开发者ID:phweda,项目名称:MFM,代码行数:23,代码来源:ListEditor.java

示例2: all

import java.util.ArrayList; //导入方法依赖的package包/类
static HashMap<String, Object> all( List<Node> lastOrdered, List<Node> predicted) {
    HashMap<String, Object> evaluations = new HashMap<>();
    ArrayList<Node> intersection = new ArrayList<>(lastOrdered);
    intersection.retainAll(predicted);

    Double precision = (double)intersection.size()/predicted.size();
    Double recall = (double) intersection.size()/lastOrdered.size();
    Double f1 = 2 * precision * recall / (precision + recall);

    evaluations.put("intersection", intersection);
    evaluations.put("precision", precision);
    evaluations.put("recall", recall);
    evaluations.put("f1", f1);

    return evaluations;
}
 
开发者ID:maxdemarzi,项目名称:instacart,代码行数:17,代码来源:Evaluations.java

示例3: cancelListOfOrders

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * take the list of orders and call hashnest to cancel them.
 * <p>on successful cancelling, remove the orders from the active list</p>
 * <p>Hashnest client exceptions will be swallowed. Logmessage will be written.</p>
 * <p>cancels will have all unsuccessful removes retained.</p>
 * @param activeOrders the list of active orders, will be modified!
 * @param cancels the list of cancellations, successful cancels are removed
 */
protected void cancelListOfOrders(List<OrderData> activeOrders, ArrayList<OrderData> cancels) {
    if(!cancels.isEmpty()) {
        log.debug("going to hashnest, will cancel {} orders", cancels.size());

        for (OrderData order : cancels) {
            try {
                client.cancelOrder(order.getId());
                log.info("Order {} cancelled in the market", order.getId());
                activeOrders.remove(order);
            } catch (HashnestServiceException e) {
                log.warn("unable to cancel order {}, cancel manually!", order.getId());
            }
        }

        // remove all elements from cancels, that are no longer active.
        cancels.retainAll(activeOrders);
    }
    else {
        log.debug("no orders cancelled.");
    }
}
 
开发者ID:asciimo71,项目名称:hashnest,代码行数:30,代码来源:LimitTradingStrategy.java

示例4: getDistinctEtats

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<String> getDistinctEtats(){
	
	ArrayList<String> etats = new ArrayList<String>();
	for(Etat etat:  Arrays.asList(Etat.values())){
		etats.add(etat.name());
	}
	List <String>  distinctEtats = Card.findDistinctEtats();
	etats.retainAll(distinctEtats);
	
	return etats;
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:12,代码来源:CardEtatService.java

示例5: intersection

import java.util.ArrayList; //导入方法依赖的package包/类
public DBag intersection(DBag otherBag) {
	read();
	ArrayList list = new ArrayList( this.bag.size() );
	list.addAll(bag);
	list.retainAll(otherBag);
	return new Bag( getSession(), list );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:Bag.java

示例6: checkForNullJoin

import java.util.ArrayList; //导入方法依赖的package包/类
protected boolean checkForNullJoin(ArrayList<String> sharedVars) {
    ArrayList<String> nullVars = new ArrayList<String>();
    nullVars.addAll(sharedVars);
    nullVars.retainAll(varsWithNulls);
    if (nullVars.isEmpty())
        return false;
    else
        return true;
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:10,代码来源:PigOpBase.java

示例7: intersection

import java.util.ArrayList; //导入方法依赖的package包/类
public boolean intersection(List<String> list1, List<String> list2) {
    ArrayList<String> result = new ArrayList<String>(list1);

    result.retainAll(list2);
    if(result.size()!=0)
    return true;
    else
        return false;
}
 
开发者ID:goutham-kalikrishna,项目名称:ShotsNewsApp,代码行数:10,代码来源:VerticalCycleAdapter.java

示例8: retainAll

import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public synchronized boolean retainAll(Collection<?> c) {
  ArrayList<E> newList = new ArrayList<E>(list);
  // Removals in ArrayList won't break sorting
  boolean changed = newList.retainAll(c);
  list = Collections.unmodifiableList(newList);
  return changed;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:SortedList.java

示例9: adaptElements

import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public IAdaptable[] adaptElements(final IAdaptable[] objects) {
	final ArrayList<IAdaptable> elements = newArrayList(getElements());
	elements.retainAll(newArrayList(objects));
	return Iterables.toArray(elements, IAdaptable.class);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:7,代码来源:WorkingSetAdapter.java

示例10: init

import java.util.ArrayList; //导入方法依赖的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();
			}
		}
	};
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:71,代码来源:NpmExportWizard.java

示例11: isCurrentOpponentsListActual

import java.util.ArrayList; //导入方法依赖的package包/类
private boolean isCurrentOpponentsListActual(ArrayList<QBUser> actualCurrentOpponentsList) {
    boolean equalActual = actualCurrentOpponentsList.retainAll(currentOpponentsList);
    boolean equalCurrent = currentOpponentsList.retainAll(actualCurrentOpponentsList);
    return !equalActual && !equalCurrent;
}
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:6,代码来源:OpponentsActivity.java


注:本文中的java.util.ArrayList.retainAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。