Java ArrayList Remove removeDuplicateWithOrder(List arrayList)

Here you can find the source of removeDuplicateWithOrder(List arrayList)

Description

remove Duplicate With Order

License

Open Source License

Declaration

public static void removeDuplicateWithOrder(List arrayList) 

Method Source Code

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

import java.util.ArrayList;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

import java.util.Set;

public class Main {

    public static void removeDuplicateWithOrder(List arrayList) {
        Set set = new HashSet();
        List newList = new ArrayList();
        for (Iterator iter = arrayList.iterator(); iter.hasNext();) {
            Object element = iter.next();
            if (set.add(element)) {
                newList.add(element);//w  w  w. j a v a 2  s  . co  m
            }
        }
        arrayList.clear();
        arrayList.addAll(newList);
    }
}

Related

  1. removeAllListaProd(ArrayList lista)
  2. removeAlreadyParsedFolders(ArrayList listStrings, String pickup, String limit)
  3. removeByReference(ArrayList list, T object)
  4. removeDuplicates(ArrayList al)
  5. removeDuplicates(ArrayList a)
  6. removeElementsFromIndexToEnd(ArrayList list, int index)
  7. removeExtraPunctuation(String line, int startChar, ArrayList indices)
  8. removeIndex(ArrayList arr, ArrayList idNames)
  9. removeLastValues(final ArrayList v, final int remove)