Quellcode durchsuchen

linked-list: make classes and methods package private (#1066)

Fixes #1055 

* make classes and methods package private #1055

* changed nested class to public

* made Element<T> private and its constructor package-private
Saatvik Arya vor 8 Jahren
Ursprung
Commit
ef231ad475

+ 6
- 6
exercises/linked-list/.meta/src/reference/java/DoublyLinkedList.java Datei anzeigen

@@ -1,7 +1,7 @@
1
-public final class DoublyLinkedList<T> {
1
+final class DoublyLinkedList<T> {
2 2
     private Element<T> head;
3 3
 
4
-    public void push(T value) {
4
+    void push(T value) {
5 5
         if (head == null) {
6 6
             head = new Element<>(value, null, null);
7 7
             head.next = head;
@@ -15,17 +15,17 @@ public final class DoublyLinkedList<T> {
15 15
         head.prev = tail;
16 16
     }
17 17
 
18
-    public T pop() {
18
+    T pop() {
19 19
         head = head.prev;
20 20
         return shift();
21 21
     }
22 22
 
23
-    public void unshift(T value) {
23
+    void unshift(T value) {
24 24
         push(value);
25 25
         head = head.prev;
26 26
     }
27 27
 
28
-    public T shift() {
28
+    T shift() {
29 29
         T value = head.value;
30 30
 
31 31
         Element<T> newHead = head.next;
@@ -48,7 +48,7 @@ public final class DoublyLinkedList<T> {
48 48
         private Element<T> prev;
49 49
         private Element<T> next;
50 50
 
51
-        public Element(T value, Element<T> prev, Element<T> next) {
51
+        Element(T value, Element<T> prev, Element<T> next) {
52 52
             this.value = value;
53 53
             this.prev = prev;
54 54
             this.next = next;