class PQ_Worklist implements IWorklist {

  private IVarAbstraction[] heap = null;
  int cur_tail = 0;

  @Override
  public void initialize(int size) {
    heap = new IVarAbstraction[size];
    cur_tail = 1;
  }

  @Override
  public boolean has_job() {
    return cur_tail > 1;
  }

  @Override
  public IVarAbstraction next() {<FILL_FUNCTION_BODY>}

  @Override
  public void push(IVarAbstraction e) {
    e.lrf_value++;

    if (e.Qpos == 0) {
      // This element has not been inserted
      int k = cur_tail;

      while (k > 1) {
        int kk = k / 2;
        if (heap[kk].lessThan(e)) {
          break;
        }
        heap[k] = heap[kk];
        heap[k].Qpos = k;
        k /= 2;
      }

      e.Qpos = k;
      heap[k] = e;
      ++cur_tail;
    } else {
      // We decrease this element whenever possible
      int k = e.Qpos;
      while ((k * 2) < cur_tail) {
        int kk = k * 2;
        if ((kk + 1) < cur_tail && heap[kk + 1].lessThan(heap[kk])) {
          kk++;
        }
        if (e.lessThan(heap[kk])) {
          break;
        }
        heap[k] = heap[kk];
        heap[kk].Qpos = k;
        k = kk;
      }
      e.Qpos = k;
      heap[k] = e;
    }
  }

  @Override
  public int size() {
    return cur_tail - 1;
  }

  @Override
  public void clear() {
    cur_tail = 1;
  }
}

    IVarAbstraction ret = heap[1];
    --cur_tail;

    if (cur_tail > 1) {
      IVarAbstraction e = heap[cur_tail];
      int k = 1;

      while ((k * 2) < cur_tail) {
        int kk = k * 2;
        if ((kk + 1) < cur_tail && heap[kk + 1].lessThan(heap[kk])) {
          kk++;
        }
        if (e.lessThan(heap[kk])) {
          break;
        }
        heap[k] = heap[kk];
        heap[k].Qpos = k;
        k = kk;
      }

      e.Qpos = k;
      heap[k] = e;
    }

    ret.Qpos = 0;
    return ret;
  
<no_super_class>