0

I am looking into creating JML specifications for the java.util.PriorityQueue.remove(Object object) method. So far I have thought of the following precondition:

//@ requires object != null;
//@ requires this.size() > 0;

I am now trying to figure out the postcondition. So what is the ensures field for this method? I feel that it should involve the size() method and making sure that the data is no longer in the queue but I am not sure how to write this.

Alex1620
  • 255
  • 1
  • 16
  • This isn't a method anyone should be using in the first place, so it is pointless to overspecify it. The only valid remove method on a `PriorityQueue` is the one with no arguments, that removes the logically first element. – user207421 Dec 08 '15 at 19:54

1 Answers1

-1

Here is the code for the method from grepcode.

 public boolean remove(Object o) {
  int i = indexOf(o);
  if (i == -1)
       return false;
  else {
       removeAt(i);
       return true;
  }
}

I would say the postcondition would be either false or true based on whether o is present in the queue or not. I am not sure whether this is what you are looking for.

Flexo
  • 87,323
  • 22
  • 191
  • 272