package org.telegram.io;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Ahmad Nemati on 1/28/19.
 */
public class Utils {


    public static List<Proxy> removeDuplicator(List<Proxy> proxyList) {


        for (int i = 0; i < proxyList.size(); i++) {
            Boolean needRemove = false;
            List<Proxy> newList = new ArrayList<>(proxyList);
            for (int j = 0; j < newList.size(); j++) {
                if (i == j)
                    continue;
                if (proxyList.get(i).getIp().equals(newList.get(j).getIp()) &&
                        proxyList.get(i).getPort() == newList.get(j).getPort() &&
                        proxyList.get(i).getSecret().equals(newList.get(j).getSecret()))
                {
                    needRemove = true;
                    break;
                }
            }

            if (needRemove) {
                proxyList.remove(i);
            }

        }

        return proxyList;
    }

}
