Procházet zdrojové kódy

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 před 8 roky
rodič
revize
ef231ad475

+ 6
- 6
exercises/linked-list/.meta/src/reference/java/DoublyLinkedList.java Zobrazit soubor

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