/** * Link this node in, infront of nde (unlinks it's self * before hand if needed). * @param nde the node to link in before. */ protected final void insertBefore(Node nde) { // Already here... if (this == nde) return; if (getPrev() != null) unlink(); // Actually insert this node... if (nde == null) { // empty lst... setNext(this); setPrev(this); } else { setNext(nde); setPrev(nde.getPrev()); nde.setPrev(this); if (getPrev() != null) getPrev().setNext(this); } } }
/** * Link this node in, infront of nde (unlinks it's self * before hand if needed). * @param nde the node to link in before. */ protected final void insertBefore(Node nde) { // Already here... if (this == nde) return; if (getPrev() != null) unlink(); // Actually insert this node... if (nde == null) { // empty lst... setNext(this); setPrev(this); } else { setNext(nde); setPrev(nde.getPrev()); nde.setPrev(this); if (getPrev() != null) getPrev().setNext(this); } } }
/** * Link this node in, infront of nde (unlinks it's self * before hand if needed). * @param nde the node to link in before. */ protected final void insertBefore(Node nde) { // Already here... if (this == nde) return; if (getPrev() != null) unlink(); // Actually insert this node... if (nde == null) { // empty lst... setNext(this); setPrev(this); } else { setNext(nde); setPrev(nde.getPrev()); nde.setPrev(this); if (getPrev() != null) getPrev().setNext(this); } } }
/** * Removes nde from the list it is part of (should be this * one, otherwise results are undefined). If nde is the * current head element, then the next element becomes head, * if there are no more elements the list becomes empty. * @param nde node to remove. */ public void remove(Node nde) { if (nde == null) return; if (nde == head) { if (head.getNext() == head) head = null; // Last node... else head = head.getNext(); } nde.unlink(); size--; }
/** * Removes nde from the list it is part of (should be this * one, otherwise results are undefined). If nde is the * current head element, then the next element becomes head, * if there are no more elements the list becomes empty. * @param nde node to remove. */ public void remove(Node nde) { if (nde == null) return; if (nde == head) { if (head.getNext() == head) head = null; // Last node... else head = head.getNext(); } nde.unlink(); size--; }
/** * Removes nde from the list it is part of (should be this * one, otherwise results are undefined). If nde is the * current head element, then the next element becomes head, * if there are no more elements the list becomes empty. * @param nde node to remove. */ public void remove(Node nde) { if (nde == null) return; if (nde == head) { if (head.getNext() == head) head = null; // Last node... else head = head.getNext(); } nde.unlink(); size--; }