diff --git a/Seminar 6/code/Lambda/.idea/.gitignore b/Seminar 6/code/Lambda/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Seminar 6/code/Lambda/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Seminar 6/code/Lambda/.idea/.name b/Seminar 6/code/Lambda/.idea/.name new file mode 100644 index 0000000..88ae8ac --- /dev/null +++ b/Seminar 6/code/Lambda/.idea/.name @@ -0,0 +1 @@ +Lambda.iml \ No newline at end of file diff --git a/Seminar 6/code/Lambda/.idea/misc.xml b/Seminar 6/code/Lambda/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/Seminar 6/code/Lambda/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Lambda/.idea/modules.xml b/Seminar 6/code/Lambda/.idea/modules.xml new file mode 100644 index 0000000..7daedb0 --- /dev/null +++ b/Seminar 6/code/Lambda/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Lambda/.idea/vcs.xml b/Seminar 6/code/Lambda/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/Seminar 6/code/Lambda/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Lambda/Lambda.iml b/Seminar 6/code/Lambda/Lambda.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Seminar 6/code/Lambda/Lambda.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Lambda/src/FuncInterface.java b/Seminar 6/code/Lambda/src/FuncInterface.java new file mode 100644 index 0000000..188283f --- /dev/null +++ b/Seminar 6/code/Lambda/src/FuncInterface.java @@ -0,0 +1,9 @@ +@FunctionalInterface +public interface FuncInterface { + //public abstract boolean canRun(); + void run(); + public static void runFast() {} + public default void runAgain() { + + } +} diff --git a/Seminar 6/code/Lambda/src/Main.java b/Seminar 6/code/Lambda/src/Main.java new file mode 100644 index 0000000..46ae5f9 --- /dev/null +++ b/Seminar 6/code/Lambda/src/Main.java @@ -0,0 +1,29 @@ +import java.util.*; + +public class Main { + public static void main(String[] args) { + List names = Arrays.asList("name 1", "Ivan", "Gosho", "Toshok", "Van"); + Map grades = new HashMap<>(); + grades.put("Ivan", 2); + grades.put("Yordan", 6); + + names.stream().parallel().filter(n -> n.contains("name")).sorted().forEach(System.out::println); + names.stream().forEach(n -> System.out.println(n)); + + List names2 = new ArrayList<>(Arrays.asList("Ivan", "Gosho", "Toshok", "Van")); + names2.removeIf(n -> n.contains("I")); + names2.forEach(n -> System.out.println(n)); + + grades.forEach((String key, Integer value) -> { System.out.println(key + " " + value); } ); + + //"Ivan", "Gosho" -> 4, 5 + +// doSth((e) -> { String f = ""; return "Poof"; }); + //n -> "" + //n -> {return ""; } + } + +// private static void doSth(Object a) { +// return "dasdasd"; +// } +} \ No newline at end of file diff --git a/Seminar 6/code/Problem6/.idea/.gitignore b/Seminar 6/code/Problem6/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Seminar 6/code/Problem6/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Seminar 6/code/Problem6/.idea/.name b/Seminar 6/code/Problem6/.idea/.name new file mode 100644 index 0000000..1ea59c3 --- /dev/null +++ b/Seminar 6/code/Problem6/.idea/.name @@ -0,0 +1 @@ +Problem6.iml \ No newline at end of file diff --git a/Seminar 6/code/Problem6/.idea/misc.xml b/Seminar 6/code/Problem6/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/Seminar 6/code/Problem6/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Problem6/.idea/modules.xml b/Seminar 6/code/Problem6/.idea/modules.xml new file mode 100644 index 0000000..5d076b2 --- /dev/null +++ b/Seminar 6/code/Problem6/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Problem6/.idea/vcs.xml b/Seminar 6/code/Problem6/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/Seminar 6/code/Problem6/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Problem6/Problem6.iml b/Seminar 6/code/Problem6/Problem6.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Seminar 6/code/Problem6/Problem6.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Seminar 6/code/Problem6/src/Main.java b/Seminar 6/code/Problem6/src/Main.java new file mode 100644 index 0000000..7f31e35 --- /dev/null +++ b/Seminar 6/code/Problem6/src/Main.java @@ -0,0 +1,14 @@ +import java.util.Arrays; +import java.util.List; + +public class Main { + public static void main(String[] args) { + List names = Arrays.asList("name 1", "Ivan", "Gosho", "Toshok", "Van"); + + //filter out names containing "name" + names.stream().filter(n -> !n.contains("name")).forEach(System.out::println); + + //sort by length + names.stream().filter(n -> !n.contains("name")).sorted((n1, n2) -> n1.length() - n2.length() ).forEach(System.out::println); + } +} \ No newline at end of file