Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Main {

    @SuppressWarnings("unchecked")
    public static void filtrerDoublonsSurPlace(List objets) {
        Map objetsDejaPresents = new HashMap();
        for (Iterator i = objets.iterator(); i.hasNext();) {
            Object objet = i.next();
            if (!objetsDejaPresents.containsKey(objet))
                objetsDejaPresents.put(objet, null);
            else
                i.remove();
        }
    }

    @SuppressWarnings("unchecked")
    public static void filtrerDoublonsSurPlace(List<Map> objets, Object filter) {
        Map objetsDejaPresents = new HashMap();
        Map filterDejaPresents = new HashMap();
        for (Iterator i = objets.iterator(); i.hasNext();) {
            Map objet = (Map) i.next();
            if (!objetsDejaPresents.containsKey(objet) && objet != null
                    && !filterDejaPresents.containsKey(objet.get(filter))) {
                objetsDejaPresents.put(objet, null);
                filterDejaPresents.put(objet.get(filter), null);
            } else
                i.remove();
        }
    }
}