2 5 8 11
public T inspector(int count) { if (count > numElements -1) throw new QueueUnderflowException(); int i; LLNode<T> curr = front; for (i = 0 ; i < count ; i++) curr = curr.getLink(); return curr.getInfo(); }
public int compareTo(Phone two) { int comp = manufact.compareTo(two.manufact); if (comp != 0) return comp; return model.compareTo(two.model); }This method must be in the Phone class.
SortedABList<Phone> phSortList = new SortedABList<>();
SortedABList<Phone> phSortList = new SortedABList<>(Phone.screenComparator());
int countBefore(ABList<Phone> phList, Phone phone) { int count = 0; Phone phoneFromList; Iterator<Phone> phIter = phList.iterator(); while (phIter.hasNext()) { phoneFromList = phIter.next(); if (phoneFromList.compareTo(phone) < 0) count++; } return count; }
void addAll(LinkedCollection<T> two) { LLNode<T> newnode; LLNode<T> temp = two.head; while (temp != null) { newnode = new LLNode<T>(temp.getInfo()); newnode.setLink(head); head = newnode; temp = temp.getLink(); } numElements += two.numElements; }
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2023