Exemple #1
0
 void add(ListNode cur) {
   ListNode lastp = tail.prev;
   lastp.next = cur;
   cur.next = tail;
   tail.prev = cur;
   cur.prev = lastp;
 }
Exemple #2
0
 public Solution(int capacity) {
   // write your code here
   this.capacity = capacity;
   len = 0;
   head = new ListNode(0, 0);
   tail = new ListNode(0, 0);
   head.next = tail;
   tail.prev = head;
   hash = new HashMap<Integer, ListNode>();
 }
Exemple #3
0
 public void addFirst(Object a) {
   ListNode tmp = new ListNode(a);
   tmp.next = head.next;
   tmp.prev = head;
   head.next = tmp;
 }
Exemple #4
0
 public void addLast(Object a) {
   ListNode tmp = new ListNode(a);
   tmp.prev = tail;
   tail.next = tmp;
   tail = tmp;
 }
Exemple #5
0
 void delete(ListNode cur) {
   ListNode lastp = cur.prev;
   ListNode nextp = cur.next;
   lastp.next = nextp;
   nextp.prev = lastp;
 }