Example usage for java.util ArrayList removeAll

List of usage examples for java.util ArrayList removeAll

Introduction

In this page you can find the example usage for java.util ArrayList removeAll.

Prototype

public boolean removeAll(Collection<?> c) 

Source Link

Document

Removes from this list all of its elements that are contained in the specified collection.

Usage

From source file:org.opendaylight.genius.itm.listeners.VtepConfigSchemaListener.java

/**
 * Handle newly added dpns to schema.//from w  w  w  . j a  va 2 s.  co  m
 *
 * @param original
 *            the original
 * @param originalDpnIds
 *            the original dpn ids
 * @param updatedDpnIds
 *            the updated dpn ids
 */
private void handleNewlyAddedDpnsToSchema(VtepConfigSchema original, List<DpnIds> originalDpnIds,
        List<DpnIds> updatedDpnIds) {
    LOG.trace("Handle Addition of DPNs from VTEP Original Dpn: {}. Updated Dpn: {}", originalDpnIds,
            updatedDpnIds);
    ArrayList<DpnIds> newlyAddedDpns = new ArrayList<>(updatedDpnIds);
    newlyAddedDpns.removeAll(originalDpnIds);
    LOG.debug("Newly added DPNs {} to VTEP config schema [{}].", newlyAddedDpns, original.getSchemaName());
    if (!newlyAddedDpns.isEmpty()) {
        VtepConfigSchema diffSchema = new VtepConfigSchemaBuilder(original).setDpnIds(newlyAddedDpns).build();
        String subnetCidr = ItmUtils.getSubnetCidrAsString(original.getSubnet());
        VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
        LOG.debug("Adding of DPNs in Diff Schema: {}", diffSchema);
        addVteps(diffSchema, vtepIpPool);
    }
}

From source file:org.apache.ddlutils.model.Database.java

/**
 * Removes all but the given tables. This method does not check whether there are foreign keys to the
 * removed tables./*  ww  w. j av  a 2 s  .  c  o  m*/
 * 
 * @param tables The tables to keep
 */
public void removeAllTablesExcept(Table[] tables) {
    ArrayList allTables = new ArrayList(_tables);

    allTables.removeAll(Arrays.asList(tables));
    _tables.removeAll(allTables);
}

From source file:net.sf.housekeeper.domain.CategoryManager.java

/**
 * Returns a list of all categories excluding a category and its children.
 * /*ww w . java2 s. c o  m*/
 * @return != null
 */
public List getAllCategoriesExcept(Category discardedCategory) {
    final ArrayList allCats = new ArrayList();
    final Iterator topLevelCats = getTopLevelCategoriesIterator();

    while (topLevelCats.hasNext()) {
        Category element = (Category) topLevelCats.next();

        final List c = element.getRecursiveCategories();
        allCats.addAll(c);
    }
    if (discardedCategory != null) {
        final List discCats = discardedCategory.getRecursiveCategories();
        allCats.removeAll(discCats);
    }

    return allCats;
}

From source file:dbseer.gui.actions.ExplainChartAction.java

@Override
public void actionPerformed(ActionEvent actionEvent) {
    if (type == DBSeerConstants.EXPLAIN_SELECT_NORMAL_REGION) {
        Set<XYItemEntity> selectedItems = panel.getSelectedItems();
        ArrayList<Double> region = panel.getNormalRegion();
        region.clear();// w  w  w . j a  v  a  2  s  .  c  o  m

        for (XYItemEntity item : selectedItems) {
            region.add(item.getDataset().getX(item.getSeriesIndex(), item.getItem()).doubleValue());
        }
        ArrayList<Double> otherRegion = panel.getAnomalyRegion();
        otherRegion.removeAll(region);
        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) panel.getChart().getXYPlot()
                .getRenderer();
        renderer.setSelectedNormal(selectedItems);
        panel.clearRectangle();
        panel.setRefreshBuffer(true);
        panel.repaint();
    } else if (type == DBSeerConstants.EXPLAIN_APPEND_NORMAL_REGION) {
        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) panel.getChart().getXYPlot()
                .getRenderer();
        Set<XYItemEntity> previousItems = renderer.getSelectedNormal();
        Set<XYItemEntity> selectedItems = panel.getSelectedItems();
        ArrayList<Double> region = panel.getNormalRegion();

        for (XYItemEntity item : selectedItems) {
            region.add(item.getDataset().getX(item.getSeriesIndex(), item.getItem()).doubleValue());
        }
        ArrayList<Double> otherRegion = panel.getAnomalyRegion();
        otherRegion.removeAll(region);
        if (previousItems != null) {
            previousItems.addAll(selectedItems);
            renderer.setSelectedNormal(previousItems);
        } else {
            renderer.setSelectedNormal(selectedItems);
        }
        panel.clearRectangle();
        panel.setRefreshBuffer(true);
        panel.repaint();
    } else if (type == DBSeerConstants.EXPLAIN_SELECT_ANOMALY_REGION) {
        Set<XYItemEntity> selectedItems = panel.getSelectedItems();
        ArrayList<Double> region = panel.getAnomalyRegion();
        region.clear();

        for (XYItemEntity item : selectedItems) {
            region.add(item.getDataset().getX(item.getSeriesIndex(), item.getItem()).doubleValue());
        }
        ArrayList<Double> otherRegion = panel.getNormalRegion();
        otherRegion.removeAll(region);
        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) panel.getChart().getXYPlot()
                .getRenderer();
        renderer.setSelectedAnomaly(selectedItems);
        panel.clearRectangle();
        panel.setRefreshBuffer(true);
        panel.repaint();
    } else if (type == DBSeerConstants.EXPLAIN_APPEND_ANOMALY_REGION) {
        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) panel.getChart().getXYPlot()
                .getRenderer();
        Set<XYItemEntity> previousItems = renderer.getSelectedAnomaly();
        Set<XYItemEntity> selectedItems = panel.getSelectedItems();
        ArrayList<Double> region = panel.getAnomalyRegion();

        for (XYItemEntity item : selectedItems) {
            region.add(item.getDataset().getX(item.getSeriesIndex(), item.getItem()).doubleValue());
        }
        ArrayList<Double> otherRegion = panel.getNormalRegion();
        otherRegion.removeAll(region);
        if (previousItems != null) {
            previousItems.addAll(selectedItems);
            renderer.setSelectedAnomaly(previousItems);
        } else {
            renderer.setSelectedAnomaly(selectedItems);
        }
        panel.clearRectangle();
        panel.setRefreshBuffer(true);
        panel.repaint();
    } else if (type == DBSeerConstants.EXPLAIN_CLEAR_REGION) {
        ArrayList<Double> region = panel.getNormalRegion();
        region.clear();
        region = panel.getAnomalyRegion();
        region.clear();

        DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) panel.getChart().getXYPlot()
                .getRenderer();
        renderer.clearAnomaly();
        renderer.clearNormal();

        DefaultListModel explanationListModel = panel.getControlPanel().getExplanationListModel();
        explanationListModel.clear();
        DefaultListModel predicateListModel = panel.getControlPanel().getPredicateListModel();
        predicateListModel.clear();

        panel.clearRectangle();
        panel.setRefreshBuffer(true);
        panel.repaint();

    } else if (type == DBSeerConstants.EXPLAIN_EXPLAIN) {
        explain();
    } else if (type == DBSeerConstants.EXPLAIN_TOGGLE_PREDICATES) {
        togglePredicates();
    } else if (type == DBSeerConstants.EXPLAIN_SAVE_PREDICATES) {
        savePredicates();
    } else if (type == DBSeerConstants.EXPLAIN_UPDATE_EXPLANATIONS) {
        updateExplanations();
    }
}

From source file:com.clust4j.algo.NNHSTests.java

License:asdf

private static int differenceInIdxArrays(int[] expected, int[] actual) {
    // Check to see if the diff is <= 2
    ArrayList<Integer> aa = new ArrayList<Integer>();
    ArrayList<Integer> bb = new ArrayList<Integer>();

    for (int in : expected)
        aa.add(in);// w ww.  ja va  2 s.c o m
    for (int in : actual)
        bb.add(in);

    ArrayList<Integer> larger = aa.size() > bb.size() ? aa : bb;
    ArrayList<Integer> smaller = aa.equals(larger) ? bb : aa;
    larger.removeAll(smaller);

    return larger.size();
}

From source file:opennlp.tools.fca.BasicLevelMetrics.java

public double simSMC(ArrayList<Integer> intent1, ArrayList<Integer> intent2) {
    int tp = (ListUtils.intersection(intent1, intent2)).size();
    ArrayList<Integer> fnlst = new ArrayList<Integer>();
    fnlst.addAll(this.attributes);
    fnlst.removeAll(ListUtils.union(intent1, intent2));
    int fn = fnlst.size();
    return (this.attributes.size() > 0) ? 1. * (tp + fn) / this.attributes.size() : 0;
}

From source file:org.squale.welcom.addons.access.excel.bd.BdAccessUpdate.java

/**
 * Mise a jour des profiles//from   www  .  j av  a2s  .  c om
 * 
 * @param jdbc : connecition
 * @param arrayFromFile : liste dans le fichie excel
 * @param arrayFromBd : liste dans la bd
 * @throws SQLException : probleme SQL
 * @return nombre de champs modifis
 */
public int updateProfile(final WJdbc jdbc, final ArrayList arrayFromFile, final ArrayList arrayFromBd)
        throws SQLException {

    int cpt = 0;
    final ArrayList noChange = new ArrayList();
    Iterator iter = arrayFromBd.iterator();

    while (iter.hasNext()) {
        final Profile profileBd = (Profile) iter.next();
        if (arrayFromFile.contains(profileBd)) {
            noChange.add(profileBd);
        }
    }

    // Suppression des doubles
    arrayFromBd.removeAll(noChange);
    arrayFromFile.removeAll(noChange);

    iter = arrayFromBd.iterator();
    while (iter.hasNext()) {
        final Profile profileBd = (Profile) iter.next();
        delete(jdbc, profileBd);
        cpt++;
    }

    iter = arrayFromFile.iterator();
    while (iter.hasNext()) {
        final Profile profileFile = (Profile) iter.next();
        create(jdbc, profileFile);
        cpt++;
    }
    return cpt;

}

From source file:org.squale.welcom.addons.access.excel.bd.BdAccessUpdate.java

/**
 * Mise a jour des access Key/* ww w  .  ja  v  a 2s .  co m*/
 * 
 * @param jdbc : connecition
 * @param arrayFromFile : liste dans le fichie excel
 * @param arrayFromBd : liste dans la bd
 * @throws SQLException : probleme SQL
 * @return Nombre de champs modifis
 */
public int updateAccessKey(final WJdbc jdbc, final ArrayList arrayFromFile, final ArrayList arrayFromBd)
        throws SQLException {

    int cpt = 0;
    final ArrayList noChange = new ArrayList();
    Iterator iter = arrayFromBd.iterator();

    while (iter.hasNext()) {
        final AccessKey accessKeyBd = (AccessKey) iter.next();
        if (arrayFromFile.contains(accessKeyBd)) {
            noChange.add(accessKeyBd);
        }
    }

    // Suppression des doubles
    arrayFromBd.removeAll(noChange);
    arrayFromFile.removeAll(noChange);

    iter = arrayFromBd.iterator();
    while (iter.hasNext()) {
        final AccessKey accessKeyBd = (AccessKey) iter.next();
        delete(jdbc, accessKeyBd);
        cpt++;
    }

    iter = arrayFromFile.iterator();
    while (iter.hasNext()) {
        final AccessKey accessKeyFile = (AccessKey) iter.next();
        create(jdbc, accessKeyFile);
        cpt++;
    }
    return cpt;
}

From source file:org.squale.welcom.addons.access.excel.bd.BdAccessUpdate.java

/**
 * Mise a jour des profiles / droits d'accs
 * /*w  ww.  j  a v a2  s  . c  o  m*/
 * @param jdbc : connecition
 * @param arrayFromFile : liste dans le fichie excel
 * @param arrayFromBd : liste dans la bd
 * @throws SQLException : probleme SQL
 * @return nombre de champs modifis
 */
public int updateProfileAccessKey(final WJdbc jdbc, final ArrayList arrayFromFile, final ArrayList arrayFromBd)
        throws SQLException {

    int cpt = 0;
    final ArrayList noChange = new ArrayList();
    Iterator iter = arrayFromBd.iterator();

    while (iter.hasNext()) {
        final ProfileAccessKey profileAccessKeyBd = (ProfileAccessKey) iter.next();
        if (arrayFromFile.contains(profileAccessKeyBd)) {
            noChange.add(profileAccessKeyBd);
        }
    }

    // Suppression des doubles
    arrayFromBd.removeAll(noChange);
    arrayFromFile.removeAll(noChange);

    iter = arrayFromBd.iterator();
    while (iter.hasNext()) {
        final ProfileAccessKey profileAccessKeyBd = (ProfileAccessKey) iter.next();
        delete(jdbc, profileAccessKeyBd);
        cpt++;
    }

    iter = arrayFromFile.iterator();
    while (iter.hasNext()) {
        final ProfileAccessKey profileAccessKeyFile = (ProfileAccessKey) iter.next();
        create(jdbc, profileAccessKeyFile);
        cpt++;
    }
    return cpt;

}

From source file:com.xamoom.android.xamoomcontentblocks.XamoomContentFragment.java

/**
 * The default behaviour is that there are only Google Play Store link ContentBlocks
 * are shown./*  w  ww .j a va 2s  .c  om*/
 *
 * All others will get removed here. Except you set {@link #displayAllStoreLinks} to true.
 *
 * @param contentBlocks ContentBlocks List to manipulate
 * @return Manipulated contetnBlocks List
 */
private ArrayList<ContentBlock> removeStoreLinks(ArrayList<ContentBlock> contentBlocks) {
    ArrayList<ContentBlock> cbToRemove = new ArrayList<>();

    for (ContentBlock contentBlock : contentBlocks) {
        if (contentBlock.getBlockType() == 4) {
            if (contentBlock.getLinkType() == 15 || contentBlock.getLinkType() == 17) {
                cbToRemove.add(contentBlock);
            }
        }
    }

    contentBlocks.removeAll(cbToRemove);
    return contentBlocks;
}