Java ArrayList Remove removeIndex(ArrayList arr, ArrayList idNames)

Here you can find the source of removeIndex(ArrayList arr, ArrayList idNames)

Description

remove all the relation index for the input array

License

Open Source License

Parameter

Parameter Description
arr The array of treatment data
idNames The array of id want be removed

Declaration

public static void removeIndex(ArrayList arr, ArrayList idNames) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.HashMap;

public class Main {
    /**/*from  w w  w .j a v  a2  s .c o m*/
     * remove all the relation index for the input array
     *
     * @param arr The array of treatment data
     * @param idNames The array of id want be removed
     */
    public static void removeIndex(ArrayList arr, ArrayList idNames) {

        for (Object item : arr) {
            if (item instanceof ArrayList) {
                removeIndex((ArrayList) item, idNames);
            } else if (item instanceof HashMap) {
                removeIndex((HashMap) item, idNames);
            }
        }

    }

    /**
     * remove all the relation index for the input map
     *
     * @param m the array of treatment data
     * @param idNames
     */
    public static void removeIndex(HashMap m, ArrayList idNames) {

        Object[] keys = m.keySet().toArray();
        for (Object key : keys) {
            Object item = m.get(key);
            if (item instanceof ArrayList) {
                removeIndex((ArrayList) item, idNames);
            } else if (item instanceof HashMap) {
                removeIndex((HashMap) item, idNames);
            } else if (item instanceof String && idNames.contains(key)) {
                m.remove(key);
            }
        }
    }
}

Related

  1. removeDuplicates(ArrayList al)
  2. removeDuplicates(ArrayList a)
  3. removeDuplicateWithOrder(List arrayList)
  4. removeElementsFromIndexToEnd(ArrayList list, int index)
  5. removeExtraPunctuation(String line, int startChar, ArrayList indices)
  6. removeLastValues(final ArrayList v, final int remove)
  7. removeNulls(ArrayList list)
  8. removeRepeatedElems(ArrayList list)