Przeglądaj źródła

Removed unecessary 'this' and type variables

Jack Mustacato 8 lat temu
rodzic
commit
b84ad20fb7

+ 8
- 8
exercises/binary-search-tree/.meta/src/reference/java/BinarySearchTree.java Wyświetl plik

9
         if (root == null) {
9
         if (root == null) {
10
             root = new Node<>(value);
10
             root = new Node<>(value);
11
         } else {
11
         } else {
12
-            this.insert(this.root, value);
12
+            insert(root, value);
13
         }
13
         }
14
-        this.nodeCount++;
14
+        nodeCount++;
15
     }
15
     }
16
 
16
 
17
     List<T> getAsSortedList() {
17
     List<T> getAsSortedList() {
18
-        List<T> result = new ArrayList<>(this.nodeCount);
19
-        this.putInSortedOrderToList(this.root, result);
18
+        List<T> result = new ArrayList<>(nodeCount);
19
+        putInSortedOrderToList(root, result);
20
         return Collections.unmodifiableList(result);
20
         return Collections.unmodifiableList(result);
21
     }
21
     }
22
 
22
 
23
     List<T> getAsLevelOrderList() {
23
     List<T> getAsLevelOrderList() {
24
-        List<T> result = new ArrayList<>(this.nodeCount);
25
-        this.putInLevelOrderToList(this.root, result);
24
+        List<T> result = new ArrayList<>(nodeCount);
25
+        putInLevelOrderToList(root, result);
26
         return Collections.unmodifiableList(result);
26
         return Collections.unmodifiableList(result);
27
     }
27
     }
28
 
28
 
33
     private void insert(Node<T> node, T value) {
33
     private void insert(Node<T> node, T value) {
34
         if (value.compareTo(node.getData()) <= 0) {
34
         if (value.compareTo(node.getData()) <= 0) {
35
             if (node.getLeft() == null) {
35
             if (node.getLeft() == null) {
36
-                node.setLeft(new Node<T>(value));
36
+                node.setLeft(new Node<>(value));
37
             } else {
37
             } else {
38
                 insert(node.getLeft(), value);
38
                 insert(node.getLeft(), value);
39
             }
39
             }
40
         } else {
40
         } else {
41
             if (node.getRight() == null) {
41
             if (node.getRight() == null) {
42
-                node.setRight(new Node<T>(value));
42
+                node.setRight(new Node<>(value));
43
             } else {
43
             } else {
44
                 insert(node.getRight(), value);
44
                 insert(node.getRight(), value);
45
             }
45
             }