1 9 package org.ozoneDB.DxLib; 10 11 17 public class DxListDeque extends DxListBag implements DxDeque { 18 19 final static long serialVersionUID = 1L; 20 21 22 24 public DxListDeque() { 25 } 26 27 28 30 public Object peek() { 31 return peekBottom(); 32 } 33 34 35 37 public Object peekTop() { 38 return top.prev().data(); 40 } 41 42 43 45 public Object peekBottom() { 46 return start.next().data(); 48 } 49 50 51 53 public synchronized void push( Object obj ) { 54 pushBottom( obj ); 55 } 56 57 58 60 public synchronized void pushTop( Object obj ) { 61 top.storeInfront( new DxListNode( obj ) ); 62 itemCount++; 63 } 64 65 66 68 public synchronized void pushBottom( Object obj ) { 69 start.storeBehind( new DxListNode( obj ) ); 70 itemCount++; 71 } 72 73 74 76 public Object pop() { 77 return popBottom(); 78 } 79 80 81 83 public Object popTop() { 84 Object answer = top.prev().data(); 85 if (answer != null) { 86 top.prev().remove(); 87 itemCount--; 88 } 89 return answer; 90 } 91 92 93 95 public Object popBottom() { 96 Object answer = start.next().data(); 97 if (answer != null) { 98 start.next().remove(); 99 itemCount--; 100 } 101 return answer; 102 } 103 } 104 | Popular Tags |