public final class DoublyLinkedList<T> {
    private Element<T> head;

    public void push(T value) {
        if (head == null) {
            head = new Element<>(value, null, null);
            head.next = head;
            head.prev = head;
            return;
        }

        Element<T> oldTail = head.prev;
        Element<T> tail = new Element<>(value, oldTail, head);
        oldTail.next = tail;
        head.prev = tail;
    }

    public T pop() {
        head = head.prev;
        return shift();
    }

    public void unshift(T value) {
        push(value);
        head = head.prev;
    }

    public T shift() {
        T value = head.value;

        Element<T> newHead = head.next;
        Element<T> newTail = head.prev;

        if (newHead == head) {
            head = null;
        }
        else {
            newHead.prev = newTail;
            newTail.next = newHead;
            head = newHead;
        }

        return value;
    }

    private static final class Element<T> {
        private final T value;
        private Element<T> prev;
        private Element<T> next;

        public Element(T value, Element<T> prev, Element<T> next) {
            this.value = value;
            this.prev = prev;
            this.next = next;
        }
    }
}

@@ -1,15 +1,8 @@
-public 
 final cl
@@ -57,31 +57,24 @@
  head;%0A%0A    
-public 
 void push(T 
@@ -423,23 +423,16 @@
  %7D%0A%0A    
-public 
 T pop() 
@@ -494,23 +494,16 @@
  %7D%0A%0A    
-public 
 void uns
@@ -576,23 +576,16 @@
  %7D%0A%0A    
-public 
 T shift(
@@ -1075,15 +1075,8 @@
     
-public 
 Elem

make classes and methods package private (#1066)