package ru.matevosyan;

import java.util.*;

public class EfficiencyList {

    private long efficiencyTime;



    public long add(Collection<String> collection, String line, int amount) {
        this.efficiencyTime = System.currentTimeMillis();
        for(int i = 0; i < amount; i++) {
            collection.add(line + i);
        }
        return this.efficiencyTime = System.currentTimeMillis() - this.efficiencyTime;
    }
    public long delete(Collection<String> collection, int amount) {
        this.efficiencyTime = System.currentTimeMillis();

        Iterator<String> iterator = collection.iterator();

        int i = 0;
        while(iterator.hasNext() && (i < amount)) {

            iterator.next();
            iterator.remove();
            i++;
        }
        return this.efficiencyTime = System.currentTimeMillis() - this.efficiencyTime;
    }

    public static void main(String[] args) {
        final String LN = System.getProperty("line.separator");
        List<String> arrayList = new ArrayList<>();
        List<String> linkedList = new LinkedList<>();
        Set<String> treeSet = new TreeSet<>();

        EfficiencyList efficiencyList = new EfficiencyList();

        //-------------------------------------------------------------

        System.out.printf("ArrayList%s", LN);

        long timeAddArray = efficiencyList.add(arrayList, "Linked", 1_000_005);
        long timeRemoveArray = efficiencyList.delete(arrayList, 1_000_000);

        System.out.print(String.format("Add time --- %s%sRemove time --- %s%s",
                timeAddArray, LN, timeRemoveArray, LN));
        int i = 0;
        for (String str : arrayList) {

            System.out.printf("%s. element --- %s%s", i++, str, LN);
        }
        System.out.printf("Amount --- %s%s%s", i, LN, LN);

        //-------------------------------------------------------------

        System.out.printf("LinkedList%s", LN);

        long timeAddLinkedList = efficiencyList.add(linkedList, "Linked", 1_000_005);
        long timeRemoveLinkedList = efficiencyList.delete(linkedList, 1_000_000);

        System.out.print(String.format("Add time --- %s%sRemove time --- %s%s", timeAddLinkedList, LN,
                timeRemoveLinkedList, LN));

        i = 0;
        for (String str : linkedList) {

            System.out.printf("%s. element --- %s%s", i++, str, LN);
        }
        System.out.printf("Amount --- %s%s%s", i, LN, LN);

        //---------------------------------------------------------------

        System.out.printf("TreeSet%s", LN);

        long timeAddTeeSet = efficiencyList.add(treeSet, "treeSet", 1_000_005);
        long timeRemoveTreeSet = efficiencyList.delete(treeSet, 1_000_000);

        System.out.printf(String.format("Add time --- %s%sRemove time  --- %s%s", timeAddTeeSet, LN,
                timeRemoveTreeSet, LN));
        i = 0;
        for (String str : treeSet) {

            System.out.printf("%s. element --- %s%s", i++, str, LN);
        }
        System.out.printf("Amount --- %s%s%s", i, LN, LN);



    }


}

@@ -868,2198 +868,6 @@
  %7D%0A%0A
-    public static void main(String%5B%5D args) %7B%0A        final String LN = System.getProperty(%22line.separator%22);%0A        List%3CString%3E arrayList = new ArrayList%3C%3E();%0A        List%3CString%3E linkedList = new LinkedList%3C%3E();%0A        Set%3CString%3E treeSet = new TreeSet%3C%3E();%0A%0A        EfficiencyList efficiencyList = new EfficiencyList();%0A%0A        //-------------------------------------------------------------%0A%0A        System.out.printf(%22ArrayList%25s%22, LN);%0A%0A        long timeAddArray = efficiencyList.add(arrayList, %22Linked%22, 1_000_005);%0A        long timeRemoveArray = efficiencyList.delete(arrayList, 1_000_000);%0A%0A        System.out.print(String.format(%22Add time --- %25s%25sRemove time --- %25s%25s%22,%0A                timeAddArray, LN, timeRemoveArray, LN));%0A        int i = 0;%0A        for (String str : arrayList) %7B%0A%0A            System.out.printf(%22%25s. element --- %25s%25s%22, i++, str, LN);%0A        %7D%0A        System.out.printf(%22Amount --- %25s%25s%25s%22, i, LN, LN);%0A%0A        //-------------------------------------------------------------%0A%0A        System.out.printf(%22LinkedList%25s%22, LN);%0A%0A        long timeAddLinkedList = efficiencyList.add(linkedList, %22Linked%22, 1_000_005);%0A        long timeRemoveLinkedList = efficiencyList.delete(linkedList, 1_000_000);%0A%0A        System.out.print(String.format(%22Add time --- %25s%25sRemove time --- %25s%25s%22, timeAddLinkedList, LN,%0A                timeRemoveLinkedList, LN));%0A%0A        i = 0;%0A        for (String str : linkedList) %7B%0A%0A            System.out.printf(%22%25s. element --- %25s%25s%22, i++, str, LN);%0A        %7D%0A        System.out.printf(%22Amount --- %25s%25s%25s%22, i, LN, LN);%0A%0A        //---------------------------------------------------------------%0A%0A        System.out.printf(%22TreeSet%25s%22, LN);%0A%0A        long timeAddTeeSet = efficiencyList.add(treeSet, %22treeSet%22, 1_000_005);%0A        long timeRemoveTreeSet = efficiencyList.delete(treeSet, 1_000_000);%0A%0A        System.out.printf(String.format(%22Add time --- %25s%25sRemove time  --- %25s%25s%22, timeAddTeeSet, LN,%0A                timeRemoveTreeSet, LN));%0A        i = 0;%0A        for (String str : treeSet) %7B%0A%0A            System.out.printf(%22%25s. element --- %25s%25s%22, i++, str, LN);%0A        %7D%0A        System.out.printf(%22Amount --- %25s%25s%25s%22, i, LN, LN);%0A%0A%0A%0A    %7D%0A%0A%0A
 %7D%0A

change methods