Chaitali Patel 6 gadus atpakaļ
vecāks
revīzija
6488e68d2a

+ 20
- 7
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java Parādīt failu

3
 /**
3
 /**
4
  * @author leon on 11/12/2018.
4
  * @author leon on 11/12/2018.
5
  */
5
  */
6
-public class ComparableTreeSet<T> {
7
-    private T value;
6
+public class ComparableTreeSet<T> implements Comparable<T> {
7
+    private T[] arr;
8
 
8
 
9
-    public ComparableTreeSet(T... arr) {
9
+    public T[] getArr() {
10
+        return arr;
10
     }
11
     }
11
 
12
 
12
-    public ComparableTreeSet(T value) {
13
-        this.value = value;
13
+    public void setArr(T[] arr) {
14
+        this.arr = arr;
14
     }
15
     }
15
 
16
 
17
+    public ComparableTreeSet(T... arr) {
18
+        this.arr =arr;
19
+    }
20
+
21
+
16
     public ComparableTreeSet() {
22
     public ComparableTreeSet() {
17
     }
23
     }
18
 
24
 
21
     }
27
     }
22
 
28
 
23
     private ComparableTreeSet<T> getValue() {
29
     private ComparableTreeSet<T> getValue() {
24
-        return (ComparableTreeSet<T>) value;
30
+       // return (ComparableTreeSet<T>) value;
31
+        return null;
25
     }
32
     }
26
 
33
 
27
     @Override
34
     @Override
28
     public String toString() {
35
     public String toString() {
29
         return "ComparableTreeSet{" +
36
         return "ComparableTreeSet{" +
30
-                "value=" + value +
37
+                "value=" + arr +
31
                 '}';
38
                 '}';
32
     }
39
     }
40
+
41
+    @Override
42
+    public int compareTo(T o) {
43
+        return 0;
44
+    }
45
+
33
 }
46
 }

+ 15
- 26
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java Parādīt failu

1
 package rocks.zipcode.io.quiz4.collections;
1
 package rocks.zipcode.io.quiz4.collections;
2
 
2
 
3
-import java.util.HashSet;
4
-import java.util.Iterator;
5
-import java.util.Set;
6
-import java.util.Spliterator;
3
+import java.util.*;
7
 import java.util.function.Consumer;
4
 import java.util.function.Consumer;
8
 
5
 
9
 import static com.sun.jmx.snmp.ThreadContext.contains;
6
 import static com.sun.jmx.snmp.ThreadContext.contains;
12
  * @author leon on 11/12/2018.
9
  * @author leon on 11/12/2018.
13
  */
10
  */
14
 public class SimpleStringGroup implements Iterable{
11
 public class SimpleStringGroup implements Iterable{
12
+
13
+    List<String> val = new ArrayList<>();
15
     public SimpleStringGroup() {
14
     public SimpleStringGroup() {
16
         //throw new UnsupportedOperationException("Method not yet implemented");
15
         //throw new UnsupportedOperationException("Method not yet implemented");
17
     }
16
     }
18
 
17
 
19
-    private final Set<String> set = new HashSet<>();
20
-
21
-
22
     public Integer count() {
18
     public Integer count() {
23
-        return set.size();
19
+        return val.size();
24
     }
20
     }
25
 
21
 
26
     public void insert(String string) {
22
     public void insert(String string) {
27
-        if (!contains(string)) {
28
-            set.add(string);
29
-        }
23
+//        if (!contains(string)) {
24
+            val.add(string);
30
     }
25
     }
31
 
26
 
32
     public Boolean has(String valueToInsert) {
27
     public Boolean has(String valueToInsert) {
33
-        return set.contains(valueToInsert);
28
+        if (val.contains(valueToInsert)){
29
+            return true;
30
+        }
31
+        return false;
34
     }
32
     }
35
 
33
 
36
     public String fetch(int indexOfValue) {
34
     public String fetch(int indexOfValue) {
37
-        //return set.add(indexOfValue);
38
-        return String.valueOf(set.equals(indexOfValue));
39
-        //return null;
35
+        return val.get(indexOfValue);
36
+
40
     }
37
     }
41
 
38
 
42
     public void delete(String valueToInsert) {
39
     public void delete(String valueToInsert) {
43
-        set.remove(valueToInsert);
40
+        val.remove(valueToInsert);
44
     }
41
     }
45
 
42
 
46
     public void clear() {
43
     public void clear() {
47
-        set.clear();
44
+        val.clear();
48
     }
45
     }
49
 
46
 
50
-   public void get() {
51
-        set.size();
52
-   }
53
-
54
     @Override
47
     @Override
55
     public Iterator iterator() {
48
     public Iterator iterator() {
56
-        return null;
49
+        return val.iterator();
57
     }
50
     }
58
 
51
 
59
     @Override
52
     @Override
60
     public void forEach(Consumer action) {
53
     public void forEach(Consumer action) {
61
     }
54
     }
62
 
55
 
63
-    @Override
64
-    public Spliterator spliterator() {
65
-        return null;
66
-    }
67
 }
56
 }

+ 1
- 1
src/main/java/rocks/zipcode/io/quiz4/generics/Group.java Parādīt failu

50
 
50
 
51
     @Override
51
     @Override
52
     public Iterator<T> iterator() {
52
     public Iterator<T> iterator() {
53
-        return null;
53
+        return list.iterator();
54
     }
54
     }
55
 
55
 
56
     @Override
56
     @Override