thats using I h8 to say it Linked Lists

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!
package 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, 1 guests, 0 anonymous users
Community Forum Software by IP.Board
Licensed to: Geeks to Go, Inc.