Java Code Examples for java.util.ArrayList.retainAll()

The following are Jave code examples for showing how to use retainAll() of the java.util.ArrayList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: MFM   File:   Source Code and License Vote up 7 votes
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)));
Example 2
Project: instacart   File:   Source Code and License Vote up 6 votes
static HashMap<String, Object> all( List<Node> lastOrdered, List<Node> predicted) {
    HashMap<String, Object> evaluations = new HashMap<>();
    ArrayList<Node> intersection = new ArrayList<>(lastOrdered);

    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;
Example 3
Project: hashnest   File:   Source Code and License Vote up 6 votes
 * 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 {
      "Order {} cancelled in the market", order.getId());
            } catch (HashnestServiceException e) {
                log.warn("unable to cancel order {}, cancel manually!", order.getId());

        // remove all elements from cancels, that are no longer active.
    else {
        log.debug("no orders cancelled.");
Example 4
Project: esup-sgc   File:   Source Code and License Vote up 5 votes
public ArrayList<String> getDistinctEtats(){
	ArrayList<String> etats = new ArrayList<String>();
	for(Etat etat:  Arrays.asList(Etat.values())){
	List <String>  distinctEtats = Card.findDistinctEtats();
	return etats;
Example 5
Project: parabuild-ci   File:   Source Code and License Vote up 5 votes
public DBag intersection(DBag otherBag) {
	ArrayList list = new ArrayList( this.bag.size() );
	return new Bag( getSession(), list );
Example 6
Project: PigSPARQL   File:   Source Code and License Vote up 5 votes
protected boolean checkForNullJoin(ArrayList<String> sharedVars) {
    ArrayList<String> nullVars = new ArrayList<String>();
    if (nullVars.isEmpty())
        return false;
        return true;
Example 7
Project: ShotsNewsApp   File:   Source Code and License Vote up 5 votes
public boolean intersection(List<String> list1, List<String> list2) {
    ArrayList<String> result = new ArrayList<String>(list1);

    return true;
        return false;
Example 8
Project: ditb   File:   Source Code and License Vote up 5 votes
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;
Example 9
Project: n4js   File:   Source Code and License Vote up 4 votes
public IAdaptable[] adaptElements(final IAdaptable[] objects) {
	final ArrayList<IAdaptable> elements = newArrayList(getElements());
	return Iterables.toArray(elements, IAdaptable.class);
Example 10
Project: n4js   File:   Source Code and License Vote up 4 votes
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 =
			.filter(m -> m instanceof IResource)
			.map(m -> ((IResource) m).getProject())
			.filter(p -> p.isOpen()) // only open projects
	// make the behavior predictable by ordering:
	TreeSet<IProject> sortedProjects = Sets
			.<IProject> newTreeSet((a, b) -> a.getName()

	// 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) {

			iP2in4jsP.put(iProject, mappedIn4jsProject);

	// filter out Non-N4JS-projects from initial selection.

	// filter out all non-N4JS-projects from the workspace projects.
	ArrayList<IProject> filteredWorkspaceProjects = new ArrayList<>(workspaceProjects);

	setWindowTitle("N4JS to npm Export");

	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() {

		public void pageChanged(PageChangedEvent event) {
			if (event.getSelectedPage() == comparePage) {
Example 11
Project: quickblox-android   File:   Source Code and License Vote up 4 votes
private boolean isCurrentOpponentsListActual(ArrayList<QBUser> actualCurrentOpponentsList) {
    boolean equalActual = actualCurrentOpponentsList.retainAll(currentOpponentsList);
    boolean equalCurrent = currentOpponentsList.retainAll(actualCurrentOpponentsList);
    return !equalActual && !equalCurrent;