home *** CD-ROM | disk | FTP | other *** search
- package COM.objectspace.jgl;
-
- import java.util.Enumeration;
-
- public class PriorityQueue implements Container {
- Array myArray;
- BinaryPredicate myComparator;
-
- public PriorityQueue() {
- this((BinaryPredicate)(new HashComparator()));
- }
-
- public PriorityQueue(BinaryPredicate var1) {
- this.myArray = new Array();
- this.myComparator = var1;
- }
-
- public PriorityQueue(PriorityQueue var1) {
- synchronized(var1){}
-
- try {
- this.myArray = (Array)var1.myArray.clone();
- this.myComparator = var1.myComparator;
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public synchronized String toString() {
- return "PriorityQueue( " + this.myArray.toString() + " )";
- }
-
- public synchronized Object clone() {
- return new PriorityQueue(this);
- }
-
- public synchronized void copy(PriorityQueue var1) {
- synchronized(var1){}
-
- try {
- if (this != var1) {
- this.myArray = (Array)var1.myArray.clone();
- this.myComparator = var1.myComparator;
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public boolean equals(Object var1) {
- return var1 instanceof PriorityQueue && this.equals((PriorityQueue)var1);
- }
-
- public synchronized boolean equals(PriorityQueue var1) {
- synchronized(var1){}
-
- boolean var2;
- try {
- var2 = this.myArray.equals(var1.myArray);
- } catch (Throwable var6) {
- throw var6;
- }
-
- return var2;
- }
-
- public synchronized int hashCode() {
- return this.myArray.hashCode();
- }
-
- public boolean isEmpty() {
- return this.myArray.isEmpty();
- }
-
- public int size() {
- return this.myArray.size();
- }
-
- public int maxSize() {
- return this.myArray.maxSize();
- }
-
- public synchronized void clear() {
- this.myArray.clear();
- }
-
- public synchronized Enumeration elements() {
- return this.myArray.elements();
- }
-
- public synchronized ForwardIterator start() {
- return this.myArray.start();
- }
-
- public synchronized ForwardIterator finish() {
- return this.myArray.finish();
- }
-
- public synchronized Object top() {
- return this.myArray.front();
- }
-
- public Object add(Object var1) {
- this.push(var1);
- return null;
- }
-
- public synchronized void push(Object var1) {
- this.myArray.pushBack(var1);
- ArrayIterator var2 = this.myArray.begin();
- ArrayIterator var3 = this.myArray.end();
- BinaryPredicate var4 = this.myComparator;
- Heap.pushHeap(var2, var2.distance(var3) - 1, 0, var3.get(-1), var4);
- }
-
- public synchronized Object pop() {
- if (this.myArray.isEmpty()) {
- throw new InvalidOperationException("PriorityQueue is empty");
- } else {
- Heap.popHeap(this.myArray.begin(), this.myArray.end(), this.myComparator);
- return this.myArray.popBack();
- }
- }
-
- public synchronized void swap(PriorityQueue var1) {
- synchronized(var1){}
-
- try {
- Array var4 = this.myArray;
- this.myArray = var1.myArray;
- var1.myArray = var4;
- BinaryPredicate var5 = this.myComparator;
- this.myComparator = var1.myComparator;
- var1.myComparator = var5;
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- public Object remove(Enumeration var1) {
- throw new InvalidOperationException("cannot execute remove() on a priority queue");
- }
-
- public int remove(Enumeration var1, Enumeration var2) {
- throw new InvalidOperationException("cannot execute remove() on a priority queue");
- }
- }
-