thats using I h8 to say it Linked Lists

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.
Create Account How it Workspackage sets_and_data_structures; private void sortByResult() { int listLength = numOfComp; for (int pass = 0; pass < listLength - 1; pass++) { for (int i = 0; i < listLength - pass - 1; i++) { if (list[i + 1].hasResult() && (!list[i].hasResult() || (list[i + 1].hasResult() && list[i].getResult() > list[i + 1].getResult()) )) { Competitor t = list[i]; list[i] = list[i + 1]; list[i + 1] = t; } } } } //sortByResult
ListNode(Competitor competitor, ListNode node) { data = competitor; nextNode = node; } ListNode getNext() { return nextNode; }
public void addCompetitor(Competitor insertItem){ if ( isEmpty() ){ // firstNode and lastNode refer to same competitor firstNode = lastNode = new ListNode(insertItem); numOfComp++; } else { // firstNode refers to new node firstNode = new ListNode(insertItem, firstNode); numOfComp++; } }
Edited by o0MattE0o, 10 June 2005 - 10:45 AM.
public void startListingByResult() { ListNode firstResult = firstNode; ListNode secoundResult = firstNode.getNext(); if (firstResult.getCompetitor().getResult() > secoundResult.getCompetitor().getResult()) { firstResult.nextNode = secoundResult.nextNode; secoundResult.nextNode = firstResult; firstNode = secoundResult; System.out.println("Linked List Sorted"); print(); } else { System.out.println("Linked List Already Sorted"); print(); } }
0 members, 0 guests, 0 anonymous users
Community Forum Software by IP.Board
Licensed to: Geeks to Go, Inc.