package Queue; /** * Class QNodeImpl represents a double linked list node. This class * is used in the implementation of the queue data structure. * * @author Thomas Wang * @version 0.55 */ public class QNodeImpl { /** the element of the node */ public Object elem; /** the previous pointer */ public QNodeImpl prev; /** the next pointer */ public QNodeImpl next; /** * Constructor, given the content of the node * @param content the content of the node */ public QNodeImpl(Object content) { this.elem = content; this.prev = null; this.next = null; } /** * Constructor, given the content of the node, and both links * @param content the content of the node * @param p the previous link * @param n the next link */ public QNodeImpl(Object content, QNodeImpl p, QNodeImpl n) { this.elem = content; this.prev = p; this.next = n; } /** * Method remove() will remove the current node from the queue. */ public void remove() { this.next.prev = this.prev; this.prev.next = this.next; this.prev = this.next = null; } /** * Method insert() will insert the current node into the queue, * given the previous node, and the next node. * * @param prevnode the previous node * @param nextnode the next node */ public void insert(QNodeImpl prevnode, QNodeImpl nextnode) { prevnode.next = nextnode.prev = this; this.prev = prevnode; this.next = nextnode; } }