diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e208459 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b69f881 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/_ATARASOV/_ATARASOV.iml b/_ATARASOV/_ATARASOV.iml new file mode 100644 index 0000000..1ab1661 --- /dev/null +++ b/_ATARASOV/_ATARASOV.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/telukhin/7/telukhin/MainTask7.java b/telukhin/7/telukhin/MainTask7.java deleted file mode 100644 index 3d40de9..0000000 --- a/telukhin/7/telukhin/MainTask7.java +++ /dev/null @@ -1,4 +0,0 @@ -package telukhin; - -public class MainTask7 { -} diff --git a/telukhin/7/telukhin/task1/MainTask7.java b/telukhin/7/telukhin/task1/MainTask7.java new file mode 100644 index 0000000..88ec882 --- /dev/null +++ b/telukhin/7/telukhin/task1/MainTask7.java @@ -0,0 +1,64 @@ +package telukhin.task1; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.TreeSet; + +public class MainTask7 { + + + public static void main(String[] args) { + ArrayList s = new ArrayList<>(); + ArrayList i = new ArrayList<>(); + ArrayList l = new ArrayList<>(); + ArrayList p = new ArrayList<>(); + + ArrayList alDouble = new ArrayList<>(); + LinkedList llDouble = new LinkedList<>(); + HashSet hsDouble = new HashSet<>(); + TreeSet tsDouble = new TreeSet<>(); + + + /*Add*/ + System.out.println("®Add 100 000 elements®********************"); + Utils.addString(s,"100000"); + Utils.addInt(i, 100000); + Utils.addLong(l, 100000L); + Utils.addPerrson(p, new PersonForAdd("Name", "Surname", 100000)); + System.out.println(); + + /*First Last Search*/ + System.out.println("®First last unExist Search®********************"); + Utils.findFirstLastUnExistString(s); + System.out.println(); + + Utils.findFirstLastUnExistInt(i); + System.out.println(); + + Utils.findFirstLastUnExistLong(l); + System.out.println(); + + Utils.findFirstLastUnExistPerson(p); + System.out.println(); + + + /*Add in different collections*/ + System.out.println("®Add First last Search in different collections®********************"); + Utils.addInArrayList(alDouble); + System.out.println(); + + Utils.addInLinkedList(llDouble); + System.out.println(); + + Utils.addInHashSet(hsDouble); + System.out.println(); + + Utils.addInTreeSet(tsDouble); + System.out.println(); + + + + } +} + diff --git a/telukhin/7/telukhin/task1/PersonForAdd.java b/telukhin/7/telukhin/task1/PersonForAdd.java new file mode 100644 index 0000000..aff70fb --- /dev/null +++ b/telukhin/7/telukhin/task1/PersonForAdd.java @@ -0,0 +1,13 @@ +package telukhin.task1; + +public class PersonForAdd { + private String name; + private String surname; + private int age; + + public PersonForAdd(String name, String surname, int age) { + this.name = name; + this.surname = surname; + this.age = age; + } +} diff --git a/telukhin/7/telukhin/task1/Utils.java b/telukhin/7/telukhin/task1/Utils.java new file mode 100644 index 0000000..2252140 --- /dev/null +++ b/telukhin/7/telukhin/task1/Utils.java @@ -0,0 +1,247 @@ +package telukhin.task1; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.TreeSet; + +public class Utils { + + /*For add different types*/ + static void addString(ArrayList list, String s) { + long beforeString = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add("100000"); + } + long timeString = System.nanoTime() - beforeString; + System.out.println("Add time string " + timeString); + } + + static void addLong(ArrayList list, long l) { + long beforeLong = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(100000L); + } + long timeLong = System.nanoTime() - beforeLong; + System.out.println("Add time long " + timeLong); + } + + static void addInt(ArrayList list, int l) { + long beforeInteger = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(100000); + } + long timeInteger = System.nanoTime() - beforeInteger; + System.out.println("Add time integer " + timeInteger); + } + + static void addPerrson(ArrayList list, PersonForAdd p) { + long beforePerson = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(p); + } + long timePerson = System.nanoTime() - beforePerson; + System.out.println("Add time person " + timePerson); + } + + /*For search*/ + static void findFirstLastUnExistString(ArrayList list) { + String first = "first"; + String last = "last"; + String unExist = "unExist"; + + list.set(0, first); + list.set(list.size() - 1, last); + + /*First element*/ + long beforeSearchFirst = System.nanoTime(); + list.contains(first); + long timeFirstInStringList = System.nanoTime() - beforeSearchFirst; + System.out.println("Search time first string element " + timeFirstInStringList); + + /*Last element*/ + long beforeSearchLast = System.nanoTime(); + list.contains(last); + long timeLastInList = System.nanoTime() - beforeSearchLast; + System.out.println("Search time last string element " + timeLastInList); + + long beforeSearchUnExist = System.nanoTime(); + list.contains(unExist); + long timeUnExistInList = System.nanoTime() - beforeSearchUnExist; + System.out.println("Search time unExist string element " + timeUnExistInList); + } + + static void findFirstLastUnExistInt(ArrayList list) { + int first = 100; + int last = 200; + int unExist = 500; + + list.set(0, first); + list.set(list.size() - 1, last); + + long beforeSearchFirst = System.nanoTime(); + list.contains(first); + long timeFirstInIntegerList = System.nanoTime() - beforeSearchFirst; + System.out.println("Search time first integer element " + timeFirstInIntegerList); + + long beforeSearchLast = System.nanoTime(); + list.contains(last); + long timeLastInStringList = System.nanoTime() - beforeSearchLast; + System.out.println("Search time last integer element " + timeLastInStringList); + + long beforeSearchUnExist = System.nanoTime(); + list.contains(unExist); + long timeUnExistInList = System.nanoTime() - beforeSearchUnExist; + System.out.println("Search time unExist integer element " + timeUnExistInList); + + + } + + static void findFirstLastUnExistLong(ArrayList list) { + long first = 100L; + long last = 200L; + long unExist = 500L; + + list.set(0, first); + list.set(list.size() - 1, last); + + long beforeSearchFirst = System.nanoTime(); + list.contains(first); + long timeFirstInIntegerList = System.nanoTime() - beforeSearchFirst; + System.out.println("Search time first long element " + timeFirstInIntegerList); + + long beforeSearchLast = System.nanoTime(); + list.contains(last); + long timeLastInStringList = System.nanoTime() - beforeSearchLast; + System.out.println("Search time last long element " + timeLastInStringList); + + long beforeSearchUnExist = System.nanoTime(); + list.contains(unExist); + long timeUnExistInList = System.nanoTime() - beforeSearchUnExist; + System.out.println("Search time unExist long element " + timeUnExistInList); + } + + static void findFirstLastUnExistPerson(ArrayList list) { + PersonForAdd first = new PersonForAdd("Name1", "Surname1", 1); + PersonForAdd last = new PersonForAdd("Name2", "Surname2", 2); + ; + PersonForAdd unExist = new PersonForAdd("Name3", "Surname3", 3); + + list.set(0, first); + list.set(list.size() - 1, last); + + long beforeSearchFirst = System.nanoTime(); + list.contains(first); + long timeFirstInIntegerList = System.nanoTime() - beforeSearchFirst; + System.out.println("Search time first person element " + timeFirstInIntegerList); + + long beforeSearchLast = System.nanoTime(); + list.contains(last); + long timeLastInStringList = System.nanoTime() - beforeSearchLast; + System.out.println("Search time last person element " + timeLastInStringList); + + long beforeSearchUnExist = System.nanoTime(); + list.contains(unExist); + long timeUnExistInList = System.nanoTime() - beforeSearchUnExist; + System.out.println("Search time unExist person element " + timeUnExistInList); + } + + /*For add in different collections*/ + static void addInArrayList(ArrayList list) { + double l = 1.1; + long before = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(l); + } + long time = System.nanoTime() - before; + System.out.println("Add time in ArrayList " + time); + + double first = 1.2; + double last = 1.3; + list.set(0, first); + list.set(list.size() - 1, last); + + long beforeFirst = System.nanoTime(); + list.contains(first); + long timeFirst = System.nanoTime() - beforeFirst; + System.out.println("Search time first in ArrayList " + timeFirst); + + long beforeLast = System.nanoTime(); + list.contains(first); + long timeLast = System.nanoTime() - beforeLast; + System.out.println("Search time last in ArrayList " + timeLast); + + } + + static void addInLinkedList(LinkedList list) { + double l = 1.1; + long before = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(l); + } + long time = System.nanoTime() - before; + System.out.println("Add time in LinkedList " + time); + + double first = 1.2; + double last = 1.3; + list.set(0, first); + list.set(list.size() - 1, last); + + long beforeFirst = System.nanoTime(); + list.contains(first); + long timeFirst = System.nanoTime() - beforeFirst; + System.out.println("Search time first in LinkedList " + timeFirst); + + long beforeLast = System.nanoTime(); + list.contains(first); + long timeLast = System.nanoTime() - beforeLast; + System.out.println("Search time last in LinkedList " + timeLast); + } + + static void addInHashSet(HashSet list) { + double l = 1; + double first = 1; + double last = 99999.0; + + long before = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(l++); + } + long time = System.nanoTime() - before; + System.out.println("Add time in HashSet " + time); + + long beforeFirst = System.nanoTime(); + list.contains(first); + long timeFirst = System.nanoTime() - beforeFirst; + System.out.println("Search time first in HashSet " + timeFirst); + + long beforeLast = System.nanoTime(); + list.contains(last); + long timeLast = System.nanoTime() - beforeLast; + System.out.println("Search time last in HashSet " + timeLast); + } + + static void addInTreeSet(TreeSet list) { + double l = 1; + double first = 1; + double last = 99999.0; + + long before = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + list.add(l++); + } + long time = System.nanoTime() - before; + System.out.println("Add time in TreeSet " + time); + + long beforeFirst = System.nanoTime(); + list.contains(first); + long timeFirst = System.nanoTime() - beforeFirst; + System.out.println("Search time first in TreeSet " + timeFirst); + + long beforeLast = System.nanoTime(); + list.contains(last); + long timeLast = System.nanoTime() - beforeLast; + System.out.println("Search time last in TreeSet " + timeLast); + } + +} diff --git a/telukhin/telukhin.iml b/telukhin/telukhin.iml deleted file mode 100644 index 0478600..0000000 --- a/telukhin/telukhin.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/terletskiy/terletskiy.iml b/terletskiy/terletskiy.iml index 591aa94..1ab1661 100644 --- a/terletskiy/terletskiy.iml +++ b/terletskiy/terletskiy.iml @@ -3,8 +3,6 @@ - - diff --git a/zudin/zudin.iml b/zudin/zudin.iml new file mode 100644 index 0000000..1ab1661 --- /dev/null +++ b/zudin/zudin.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file