You are here: Home Demos Lecture 22 PriorityQueue.java

PriorityQueue.java

Plain Text icon PriorityQueue.java — Plain Text, 1005 bytes

File contents

//@ model import org.jmlspecs.models.JMLObjectBag;

public abstract class PriorityQueue {
    
    //@ public nullable model JMLObjectBag queue; 
    //@ ghost non_null JMLObjectBag ghostQueue; in queue;
    //@ private represents queue <- ghostQueue;

    public PriorityQueue() {
	//@ set ghostQueue = new JMLObjectBag();
    }

    /*@ public normal_behavior
      @  ensures queue.equals(\old(queue).insert(o));
      @  modifies queue;
      @*/
    public abstract void enqueue(/*@non_null@*/ Comparable o);
    
    /*@ public normal_behavior
      @  requires !isEmpty();
      @  ensures \old(queue).has(\result) &&
      @       queue.equals(\old(queue).remove(\result)) &&
      @   (\forall Comparable o; queue.has(o); \result.compareTo(o) <= 0);
      @  modifies queue;
      @*/
    public abstract /*@non_null@*/ Comparable removeFirst();
    
    /*@ public normal_behavior
      @  ensures \result == (queue.isEmpty());
      @*/
    public abstract /*@pure@*/ boolean isEmpty();
    
}