swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swarm-Support] QSort and its compare function


From: Steve Railsback
Subject: [Swarm-Support] QSort and its compare function
Date: Thu, 10 Nov 2005 17:13:24 -0800
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

I'm not getting QSort to work in Java. The 'compare' method is never called, so I suspect I have not given it the right name. (I can also provide a tiny test code but I suspect the problem is simple.)

Here is my compare function, in the agent class:

public int compare(StupidBug otherBug) {
        double otherBugSize = otherBug.getMySize();
        System.out.println("Hello from compare- this does not print");
        if (mySize > otherBugSize) return -1;
        else if (mySize < otherBugSize)      return 1;
        else return 0;
        }


Here is the sort method, in the model swarm:

public void sortBugs() {
        System.out.println("Hello from sortBugs- this prints");
        bugSorter.sortObjectsIn(bugList);
}

And I created the QSort this way:

                bugSorter = new QSortImpl (getZone());


Thanks,

Steve
--
Lang Railsback & Assoc.
250 California Ave.
Arcata, California 95521
(707) 822-0453


reply via email to

[Prev in Thread] Current Thread [Next in Thread]