public void traverse(LLNode<T> first) { LLNode<T> curr; for (curr = first ; curr != null ; curr = curr.getLink()) System.out.println(curr.getInfo()); }
public int delone(LLNode<T> first) { if (first != null) first = first.getLink(); } }
public void delEnd(LLNode<T> first) { LLNode<T> curr = first; if (first == null) return; if (first.getLink() == null) { first = null; return; } while (curr.getLink().getLink() != null) curr = curr.getLink(); curr.setLink(null); }
// we can change first without destroying the list because // first is passed by value, so even though we change it inside // the function, the original value will be unchanged boolean search(LLNode<T> first, T item) { if (first == null) return false; while (first != null) { if (first.getInfo().equals(item)) return true; first = first.getLink(); } return false; }
15 15 10
5 maybe 5
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2009