boolean insert(Pair dataPtr) { ListNode prevPtr; ListNode nodePtr; ListNode currPtr; prevPtr = findPrevious(dataPtr); currPtr = prevPtr.nextPtr; if ((currPtr != null) && (currPtr.dataPtr.firstPtr.compareTo(dataPtr.firstPtr) == 0)) { return false; } nodePtr = new ListNode(dataPtr); nodePtr.nextPtr = currPtr; prevPtr.nextPtr = nodePtr; size++; return true; }
public List() { head = new ListNode(); head.dataPtr = null; head.nextPtr = null; size = 0; }