public void add(int index, Node nde) { if (nde == null) return; if (index == 0) { // This makes it the first element in the list. nde.insertBefore(head); head = nde; } else if (index == size) { // Because the list is circular this // makes it the last element in the list. nde.insertBefore(head); } else { Node after = head; while (index != 0) { after = after.getNext(); index--; } nde.insertBefore(after); } size++; }
public void add(int index, Node nde) { if (nde == null) return; if (index == 0) { // This makes it the first element in the list. nde.insertBefore(head); head = nde; } else if (index == size) { // Because the list is circular this // makes it the last element in the list. nde.insertBefore(head); } else { Node after = head; while (index != 0) { after = after.getNext(); index--; } nde.insertBefore(after); } size++; }
public void add(int index, Node nde) { if (nde == null) return; if (index == 0) { // This makes it the first element in the list. nde.insertBefore(head); head = nde; } else if (index == size) { // Because the list is circular this // makes it the last element in the list. nde.insertBefore(head); } else { Node after = head; while (index != 0) { after = after.getNext(); index--; } nde.insertBefore(after); } size++; }
/** * Adds <code>nde</code> to the head of the list. * In perl this is called an 'unpop'. <code>nde</code> should * not currently be part of any list. * @param nde the node to add to the list. */ public void add(Node nde) { if (nde == null) return; nde.insertBefore(head); head = nde; size++; }
/** * Moves <code>nde</code> to the head of the list (equivilent to * remove(nde); add(nde); but faster. */ public void touch(Node nde) { if (nde == null) return; nde.insertBefore(head); head = nde; }
/** * Adds <code>nde</code> to head of list */ public void unpop(Node nde) { nde.insertBefore(head); head = nde; size++; } }
/** * Adds <code>nde</code> to head of list */ public void unpop(Node nde) { nde.insertBefore(head); head = nde; size++; } }
/** * Adds <code>nde</code> to head of list */ public void unpop(Node nde) { nde.insertBefore(head); head = nde; size++; } }
/** * Moves <code>nde</code> to the head of the list (equivilent to * remove(nde); add(nde); but faster. */ public void touch(Node nde) { if (nde == null) return; nde.insertBefore(head); head = nde; }
/** * Adds <code>nde</code> to tail of list */ public void push(Node nde) { nde.insertBefore(head); if (head == null) head = nde; size++; }
/** * Adds <code>nde</code> to tail of list */ public void push(Node nde) { nde.insertBefore(head); if (head == null) head = nde; size++; }
/** * Adds <code>nde</code> to the head of the list. * In perl this is called an 'unpop'. <code>nde</code> should * not currently be part of any list. * @param nde the node to add to the list. */ public void add(Node nde) { if (nde == null) return; nde.insertBefore(head); head = nde; size++; }
/** * Adds <code>nde</code> to tail of list */ public void push(Node nde) { nde.insertBefore(head); if (head == null) head = nde; size++; }
/** * Moves <code>nde</code> to the head of the list (equivilent to * remove(nde); add(nde); but faster. */ public void touch(Node nde) { if (nde == null) return; nde.insertBefore(head); head = nde; }
/** * Adds <code>nde</code> to the head of the list. * In perl this is called an 'unpop'. <code>nde</code> should * not currently be part of any list. * @param nde the node to add to the list. */ public void add(Node nde) { if (nde == null) return; nde.insertBefore(head); head = nde; size++; }