From 758c5f7319765ed5b1fb352dfd6eca7d67c57162 Mon Sep 17 00:00:00 2001 From: maverick Date: Thu, 29 Sep 2016 15:06:45 +0530 Subject: [PATCH] Removed files not useful in this branch for MD5 article. --- .../java/com/baeldung/beans/Employee.java | 49 --------- .../org/baeldung/java/sorting/ArraySort.java | 103 ----------------- .../baeldung/java/sorting/ComparingTest.java | 38 ------- .../org/baeldung/java/sorting/Employee.java | 54 --------- .../org/baeldung/java/sorting/ListSort.java | 59 ---------- .../org/baeldung/java/sorting/MapSort.java | 104 ------------------ .../java/sorting/NaturalOrderExample.java | 34 ------ .../org/baeldung/java/sorting/SetSort.java | 54 --------- 8 files changed, 495 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/beans/Employee.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/ArraySort.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/ComparingTest.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/Employee.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/ListSort.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/MapSort.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/NaturalOrderExample.java delete mode 100644 core-java/src/test/java/org/baeldung/java/sorting/SetSort.java diff --git a/core-java/src/main/java/com/baeldung/beans/Employee.java b/core-java/src/main/java/com/baeldung/beans/Employee.java deleted file mode 100644 index 78d65e18fe..0000000000 --- a/core-java/src/main/java/com/baeldung/beans/Employee.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.baeldung.beans; - -public class Employee implements Comparable{ - private String name; - private int age; - private double salary; - - public Employee() { - - } - - public Employee(String name, int age, double salary) { - super(); - this.name = name; - this.age = age; - this.salary = salary; - } - - public int getAge() { - return age; - } - public void setAge(int age) { - this.age = age; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public double getSalary() { - return salary; - } - public void setSalary(double salary) { - this.salary = salary; - } - - @Override - public String toString() { - return "("+name+","+age+","+salary+")"; - - } - - @Override - public int compareTo(Object o) { - Employee e = (Employee) o; - return getAge() - e.getAge() ; - } -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/ArraySort.java b/core-java/src/test/java/org/baeldung/java/sorting/ArraySort.java deleted file mode 100644 index 35e6c8b46d..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/ArraySort.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.baeldung.java.sorting; - -import static org.junit.Assert.*; - -import java.sql.Array; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -public class ArraySort { - - private int[] numbers; - private Integer[] integers; - private String[] names; - private Employee[] employees; - - @Before - public void initData() { - numbers = new int[] { 5, 1, 89, 255, 7, 88, 200, 123, 66 }; - integers = new Integer[] { 5, 1, 89, 255, 7, 88, 200, 123, 66 }; - - names = new String[] { "John", "Apple", "Steve", "Frank", "Earl", "Jessica", "Jake", "Pearl" }; - - employees = new Employee[] { new Employee("John", 23, 5000), new Employee("Steve", 26, 6000), new Employee("Frank", 33, 7000), - new Employee("Earl", 43, 10000), new Employee("Jessica", 23, 4000), new Employee("Pearl", 33, 6000) }; - - } - - @Test - public void naturalSortIntArray() { - - Arrays.sort(numbers); - - } - - @Test - public void comparatorSortIntArray() { - - Arrays.sort(integers, new Comparator() { - - @Override - public int compare(Integer a, Integer b) { - return a - b; - } - }); - - } - - @Test - public void givenArray_whenUsingSortWithLambdas_thenSortedArray() { - Arrays.sort(integers, (a, b) -> { - return a - b; - }); - - } - - @Test - public void comparableSortEmployeeArrayByAge_NaturalOrder() { - - Arrays.sort(employees); - - } - - @Test - public void comparatorSortEmployeeArrayByName() { - Arrays.sort(employees, new Comparator() { - - @Override - public int compare(Employee o1, Employee o2) { - - return o1.getName().compareTo(o2.getName()); - } - }); - } - - @Test - public void comparatorSortEmployeeArrayByName_Java8Lambda() { - Arrays.sort(employees, (o1, o2) -> { - return o1.getName().compareTo(o2.getName()); - - }); - } - - @Test - public void givenIntArray_whenUsingRangeSort_thenRangeSortedArray() { - System.out.println(Arrays.toString(numbers)); - Arrays.sort(numbers, 3, 7); - System.out.println(Arrays.toString(numbers)); - - } - - @Test - public void givenIntArray_whenUsingParallelSort_thenParallelSortedArray() { - - Arrays.parallelSort(numbers); - - } - -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/ComparingTest.java b/core-java/src/test/java/org/baeldung/java/sorting/ComparingTest.java deleted file mode 100644 index 02cdede7db..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/ComparingTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.baeldung.java.sorting; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -public class ComparingTest { - - private List employees; - - @Before - public void initData() { - - // employees = Arrays.asList(new Employee[] { - // new Employee("John", 23, 5000), - // new Employee("Steve", 26, 6000), - // new Employee("Frank", 33, 7000), - // new Employee("Earl", 43, 10000), - // new Employee("Jessica", 23, 4000), - // new Employee("Pearl", 33, 6000) }); - - } - - @Test - public void testComparing() { - employees = Arrays.asList(new Employee[] { new Employee("John", 23, 5000), new Employee("Steve", 26, 6000), new Employee("Frank", 33, 7000), - new Employee("Earl", 43, 10000), new Employee("Jessica", 23, 4000), new Employee("Pearl", 33, 6000) }); - - employees.sort(Comparator.comparing(Employee::getAge).thenComparing(Employee::getName)); - - } - -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/Employee.java b/core-java/src/test/java/org/baeldung/java/sorting/Employee.java deleted file mode 100644 index f36e552daf..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/Employee.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.baeldung.java.sorting; - -public class Employee implements Comparable { - private String name; - private int age; - private double salary; - - public Employee() { - - } - - public Employee(String name, int age, double salary) { - super(); - this.name = name; - this.age = age; - this.salary = salary; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public double getSalary() { - return salary; - } - - public void setSalary(double salary) { - this.salary = salary; - } - - @Override - public String toString() { - return "(" + name + "," + age + "," + salary + ")"; - - } - - @Override - public int compareTo(Object o) { - Employee e = (Employee) o; - return getAge() - e.getAge(); - } -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/ListSort.java b/core-java/src/test/java/org/baeldung/java/sorting/ListSort.java deleted file mode 100644 index 91e1c40607..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/ListSort.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.baeldung.java.sorting; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -public class ListSort { - - private List integers; - private List employees; - - @Before - public void initData() { - integers = Arrays.asList(new Integer[] { 5, 1, 89, 255, 7, 88, 200, 123, 66 }); - - employees = Arrays.asList(new Employee[] { new Employee("John", 23, 5000), new Employee("Steve", 26, 6000), new Employee("Frank", 33, 7000), - new Employee("Earl", 43, 10000), new Employee("Jessica", 23, 4000), new Employee("Pearl", 33, 6000) }); - } - - @Test - public void naturalOrderIntegerListSort() { - - Collections.sort(integers); - - } - - @Test - public void comparableEmployeeSortByAge() { - - Collections.sort(employees); - - } - - @Test - public void comparatorEmployeeSortByName() { - - Collections.sort(employees, new Comparator() { - @Override - public int compare(Employee e1, Employee e2) { - return e1.getName().compareTo(e2.getName()); - } - }); - - } - - @Test - public void comparatorEmployeeSortByNameJava8() { - - Collections.sort(employees, (e1, e2) -> { - return e1.getName().compareTo(e1.getName()); - }); - - } - -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/MapSort.java b/core-java/src/test/java/org/baeldung/java/sorting/MapSort.java deleted file mode 100644 index 1a9fd30437..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/MapSort.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.baeldung.java.sorting; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; - -import org.junit.Before; -import org.junit.Test; - -public class MapSort { - - HashMap map; - - @Before - public void initData() { - map = new HashMap<>(); - - map.put(55, "John"); - map.put(22, "Apple"); - map.put(66, "Earl"); - map.put(77, "Pearl"); - map.put(12, "George"); - map.put(6, "Rocky"); - - } - - @Test - public void sortMapByKeys() { - - - List> entries = new ArrayList<>(map.entrySet()); - - Collections.sort(entries, new Comparator>() { - - @Override - public int compare(Entry o1, Entry o2) { - - return o1.getKey().compareTo(o2.getKey()); - } - }); - - HashMap sortedMap = new LinkedHashMap<>(); - - for (Map.Entry entry : entries) { - sortedMap.put(entry.getKey(), entry.getValue()); - } - - - } - - @Test - public void sortMapByValues() { - - //showMap(map); - - List> entries = new ArrayList<>(map.entrySet()); - - Collections.sort(entries, new Comparator>() { - - @Override - public int compare(Entry o1, Entry o2) { - return o1.getValue().compareTo(o2.getValue()); - } - }); - - HashMap sortedMap = new LinkedHashMap<>(); - for (Map.Entry entry : entries) { - sortedMap.put(entry.getKey(), entry.getValue()); - } - -/// showMap(sortedMap); - } - - @Test - public void sortMapViaTreeMap() { - -// showMap(map); - Map treeMap = new TreeMap<>(new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o1 - o2; - } - }); - - treeMap.putAll(map); -// showMap(treeMap); - - } - - public void showMap(Map map1) { - for (Map.Entry entry : map1.entrySet()) { - System.out.println("[Key: " + entry.getKey() + " , " + "Value: " + entry.getValue() + "] "); - - } - - } - -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/NaturalOrderExample.java b/core-java/src/test/java/org/baeldung/java/sorting/NaturalOrderExample.java deleted file mode 100644 index bb35557561..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/NaturalOrderExample.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.baeldung.java.sorting; - -import java.util.Arrays; -import java.util.Comparator; - -import org.junit.Test; - -public class NaturalOrderExample { - - @Test - public void sortArray() { - int[] numbers = new int[] { 5, 1, 89, 255, 7, 88, 200, 123, 66 }; - - Arrays.sort(numbers); - - } - - @Test - public void sortEmployees() { - Employee[] employees = new Employee[] { new Employee("John", 23, 5000), new Employee("Steve", 26, 6000), new Employee("Frank", 33, 7000), - new Employee("Earl", 43, 10000), new Employee("Jessica", 23, 4000), new Employee("Pearl", 33, 6000) }; - - Arrays.sort(employees, new Comparator() { - - @Override - public int compare(Employee o1, Employee o2) { - return -(int) (o1.getSalary() - o2.getSalary()); - } - }); - - - } - -} diff --git a/core-java/src/test/java/org/baeldung/java/sorting/SetSort.java b/core-java/src/test/java/org/baeldung/java/sorting/SetSort.java deleted file mode 100644 index d892223862..0000000000 --- a/core-java/src/test/java/org/baeldung/java/sorting/SetSort.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.baeldung.java.sorting; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.TreeSet; - -import org.junit.Before; -import org.junit.Test; - -public class SetSort { - - private HashSet integers; - private TreeSet employees; - - @Before - public void initData() { - - integers = new HashSet<>(); - integers.addAll(Arrays.asList(new Integer[] { 5, 1, 89, 255, 7, 88, 200, 123, 66 })); - - employees = new TreeSet<>(); - - employees.addAll(Arrays.asList(new Employee[] { new Employee("John", 23, 5000), new Employee("Steve", 26, 6000), - new Employee("Frank", 33, 7000), new Employee("Earl", 43, 10000), new Employee("Jessica", 23, 4000), new Employee("Pearl", 33, 6000) })); - - } - - @Test - public void hashSetSortIntegers() { - - - - ArrayList list = new ArrayList(integers); - Collections.sort(list, (i1, i2) -> { - return i2 - i1; - }); - - - } - - @Test - public void treeSetEmployeeSorting() { - - ArrayList list = new ArrayList(employees); - Collections.sort(list, (e1, e2) -> { - return e2.getName().compareTo(e1.getName()); - }); - - } - -}