/[gzz]/gzz/gzz/util/PriorityQueue.java
ViewVC logotype

Diff of /gzz/gzz/util/PriorityQueue.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by tjl, Fri Jan 10 19:23:34 2003 UTC revision 1.4 by tjl, Fri Jan 10 19:53:17 2003 UTC
# Line 8  import java.util.*; Line 8  import java.util.*;
8   * N.B. the current implementation is not the most efficient   * N.B. the current implementation is not the most efficient
9   * possible one,   * possible one,
10   * by far.   * by far.
11     * <p>
12     * This class is not synchronized!
13   */   */
14    
15  public class PriorityQueue {  public class PriorityQueue {
# Line 44  public class PriorityQueue { Line 46  public class PriorityQueue {
46       * If the job has already been added, set the priority       * If the job has already been added, set the priority
47       * to the lower value (more important) of the two.       * to the lower value (more important) of the two.
48       */       */
49      public synchronized void add(Object job, int priority) {      public void add(Object job, int priority) {
50          Integer prevprio = (Integer)jobPriority.get(job);          Integer prevprio = (Integer)jobPriority.get(job);
51          if(prevprio != null) {          if(prevprio != null) {
52              if(priority >= prevprio.intValue()) return;              if(priority >= prevprio.intValue()) return;
# Line 61  public class PriorityQueue { Line 63  public class PriorityQueue {
63      /** Get the most important (with lowest numeric priority) job and remove      /** Get the most important (with lowest numeric priority) job and remove
64       * it from this queue.       * it from this queue.
65       */       */
66      public synchronized Object getAndRemoveLowest() {      public Object getAndRemoveLowest() {
67          if(jobs.isEmpty()) return null;          if(jobs.isEmpty()) return null;
68          Object j = jobs.first();          Object j = jobs.first();
69          jobs.remove(j);          jobs.remove(j);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26