/** * Adds a node to the end of the list. * * @param node the node to add to the beginning of the list. */ public LinkedListNode<E> addLast(LinkedListNode<E> node) { return node.insert(head, head.previous); }
/** * Adds a node to the beginning of the list. * * @param node the node to add to the beginning of the list. */ public LinkedListNode<E> addFirst(LinkedListNode<E> node) { return node.insert(head.next, head); }
/** * Constructs a new linked list node. * * @param object the Object that the node represents. * @param next a reference to the next LinkedListNode in the list. * @param previous a reference to the previous LinkedListNode in the list. */ public LinkedListNode(E object, LinkedListNode<E> next, LinkedListNode<E> previous) { if (next != null && previous != null) { this.insert(next, previous); } this.object = object; }
/** * Adds a node to the beginning of the list. * * @param node the node to add to the beginning of the list. */ public LinkedListNode<E> addFirst(LinkedListNode<E> node) { return node.insert(head.next, head); }
/** * Adds a node to the end of the list. * * @param node the node to add to the beginning of the list. */ public LinkedListNode<E> addLast(LinkedListNode<E> node) { return node.insert(head, head.previous); }
/** * Constructs a new linked list node. * * @param object the Object that the node represents. * @param next a reference to the next LinkedListNode in the list. * @param previous a reference to the previous LinkedListNode in the list. */ public LinkedListNode(E object, LinkedListNode<E> next, LinkedListNode<E> previous) { if (next != null && previous != null) { this.insert(next, previous); } this.object = object; }