]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/lib/include/pqueue.hh
release: 0.0.42
[lilypond.git] / flower / lib / include / pqueue.hh
index 195232317e17f58e268833afe3bbb9db1817e02f..c8dfe1bea6754f8786e8460e9b91231c02733b01 100644 (file)
@@ -15,6 +15,8 @@
 /**
   Stupid Prioq. Should use Lists and STL.
   Smallest is put at the front.
+
+Actually, this sux. Should use a template struct PQuee_ent<V,I>
  */
 
 template<class V, class I>
@@ -22,23 +24,47 @@ struct PQueue
 {
     Array<V> value_arr_;
     Array<I> indices_arr_;
-
+    void OK() const 
+    {
+       
+       assert(value_arr_.size() == indices_arr_.size());
+    }
+    
     void enter(V v, I idx) {
        int j=0;
        for (; j < value_arr_.size(); j++)
            if (indices_arr_[j] > idx) 
                break;
 
-       value_arr_.insert(v, j);
-       indices_arr_.insert(idx, j);
+       insert(j,v,idx);
+       
     }
     int size() { return value_arr_.size(); }
     V front_val() { return value_arr_[0]; }
     I front_idx() { return indices_arr_[0]; }
+    void del(int i) 
+    {
+       value_arr_.del(i);
+       indices_arr_.del(i);
+    }
+    int size() const
+    {
+       OK();
+       return value_arr_.size();
+    }
+    
+
+    void insert(int j, V v, I idx)
+    {
+       value_arr_.insert(v, j);
+       indices_arr_.insert(idx, j);
+    }
+    
+
+
     V get() {
        V retval = front_val();
-       value_arr_.del(0);
-       indices_arr_.del(0);
+       del(0);
        return retval;
     }