Java List Remove Duplicate removeDublicates(List l)

Here you can find the source of removeDublicates(List l)

Description

remove Dublicates

License

Open Source License

Declaration

public static <T> void removeDublicates(List<T> l) 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

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

import java.util.List;

import java.util.Set;

public class Main {
    public static <T> void removeDublicates(List<T> l) {
        final Set<T> set = new HashSet<T>();
        for (Iterator<T> it = l.iterator(); it.hasNext();) {
            final T t = it.next();
            if (!set.add(t)) {
                it.remove();//  ww  w.  j a v a  2 s  .c o m
            }
        }
    }
}

Related

  1. removeDup(List lst)
  2. removeDuplicate(Collection entityList)
  3. removeDuplicate(List uidList)
  4. removeDuplicate(List dest, List src)