1 package DEOS; 20 21 24 class threadList extends DoubleLinkListNode { 25 protected threadList () { 26 previous = this; 28 next = this; 29 } 30 31 public boolean isEmpty () { 32 return next == (threadList) this; 33 } 34 35 protected void addAtBeginning (threadListNode newNode) { 36 addAfter(newNode); 37 } 38 39 protected void addAtEnd (threadListNode newNode) { 40 previous.addAfter(newNode); 42 } 43 44 protected threadListNode head () { 45 if (isEmpty()) { 46 System.out.println("Attempt to acquire head of empty list!"); 47 System.exit(0); 48 } 49 50 return (threadListNode) next; 51 } 52 53 protected void mergeList (threadList otherList) { 54 if (!otherList.isEmpty()) { 56 previous.next = otherList.next; 57 otherList.next.previous = previous; 58 previous = otherList.previous; 59 otherList.previous.next = this; 60 otherList.next = otherList; 61 otherList.previous = otherList; 62 } 63 } 64 65 protected threadListNode tail () { 66 if (isEmpty()) { 67 System.out.println("Attempt to acquire tail of empty list!"); 68 System.exit(0); 69 } 70 71 return (threadListNode) previous; 72 } 73 } | Popular Tags |