
package kr.ac.kaist.ds.groupd.search;

import java.util.Comparator;
import java.util.PriorityQueue;

public class SearchQueryPriorityQueue<E> extends PriorityQueue<E> {
    private static final long serialVersionUID = 1L;

    private final int fixedSizeOfQueue;

    public SearchQueryPriorityQueue(int initialCapacity, Comparator<? super E> comparator) {
        super(initialCapacity, comparator);
        this.fixedSizeOfQueue = initialCapacity;
    }

    @Override
    public boolean offer(E e) {
        
        if(this.contains(e))
            return false;
        
        if (this.size() >= fixedSizeOfQueue) {
            if (null != remove())
                return super.offer(e);
            
            return false;
        }
        
        return super.offer(e);
    }

}

@@ -497,24 +497,16 @@
 (E e) %7B%0A
-        
 %0A       
@@ -508,16 +508,17 @@
       if
+ 
 (this.co
@@ -554,25 +554,17 @@
  false;%0A
-        
 %0A
+
         
@@ -606,42 +606,146 @@
 ) %7B%0A
-            if (null != remove())%0A
+%0A            E element = remove();%0A%0A            if (null != element)%0A                if (this.comparator().compare(element, e) == -1)%0A    
     
@@ -779,28 +779,16 @@
 fer(e);%0A
-            
 %0A       
@@ -816,24 +816,16 @@
       %7D%0A
-        
 %0A       

solve the problem using comparator() at SearchQueryPriorityQueue