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

Diff of /classpath/java/util/PriorityQueue.java

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

revision 1.1.2.1 by tromey, Mon Aug 16 19:23:49 2004 UTC revision 1.1.2.2 by gnu_andrew, Mon Jan 10 18:25:48 2005 UTC
# Line 1  Line 1 
1  /* PriorityQueue.java -- Unbounded priority queue  /* PriorityQueue.java -- Unbounded priority queue
2     Copyright (C) 2004 Free Software Foundation, Inc.     Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package java.util;  package java.util;
40    
41  /**  /**
42     * @author Tom Tromey (tromey@redhat.com)
43     * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
44   * @since 1.5   * @since 1.5
45   */   */
46  public class PriorityQueue<E> extends AbstractQueue<E>  public class PriorityQueue<E> extends AbstractQueue<E>
# Line 71  public class PriorityQueue<E> extends Ab Line 73  public class PriorityQueue<E> extends Ab
73      this(Math.max(1, (int) (1.1 * c.size())), null);      this(Math.max(1, (int) (1.1 * c.size())), null);
74    
75      // Special case where we can find the comparator to use.      // Special case where we can find the comparator to use.
76      if (c instanceof SortedSet<? extends E>)      if (c instanceof SortedSet)
77        {        {
78          SortedSet<? extends E> ss = (SortedSet<? extends E>) c;          SortedSet<? extends E> ss = (SortedSet<? extends E>) c;
79          this.comparator = ss.comparator();          this.comparator = ss.comparator();
# Line 84  public class PriorityQueue<E> extends Ab Line 86  public class PriorityQueue<E> extends Ab
86              storage[i++] = val;              storage[i++] = val;
87            }            }
88        }        }
89      else if (c instanceof PriorityQueue<? extends E>)      else if (c instanceof PriorityQueue)
90        {        {
91          PriorityQueue<? extends E> pq = (PriorityQueue<? extends E>) c;          PriorityQueue<? extends E> pq = (PriorityQueue<? extends E>) c;
92          this.comparator = pq.comparator();          this.comparator = pq.comparator();
# Line 103  public class PriorityQueue<E> extends Ab Line 105  public class PriorityQueue<E> extends Ab
105    public PriorityQueue(int cap, Comparator<? super E> comp)    public PriorityQueue(int cap, Comparator<? super E> comp)
106    {    {
107      this.used = 0;      this.used = 0;
108      this.storage = new E[cap];      this.storage = (E[]) new Object[cap];
109      this.comparator = comp;      this.comparator = comp;
110    }    }
111    
# Line 158  public class PriorityQueue<E> extends Ab Line 160  public class PriorityQueue<E> extends Ab
160          return storage[index];          return storage[index];
161        }        }
162    
163        void remove()        public void remove()
164        {        {
165          remove(index);          PriorityQueue.this.remove(index);
166        }        }
167      };      };
168    }    }
# Line 317  public class PriorityQueue<E> extends Ab Line 319  public class PriorityQueue<E> extends Ab
319    
320    void resize()    void resize()
321    {    {
322      E[] new_data = new E[2 * storage.length];      E[] new_data = (E[]) new Object[2 * storage.length];
323      System.arraycopy(storage, 0, new_data, 0, storage.length);      System.arraycopy(storage, 0, new_data, 0, storage.length);
324      storage = new_data;      storage = new_data;
325    }    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

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