From f5fcb255d787846e955ca90d8cf9f8617a2c548c Mon Sep 17 00:00:00 2001 From: fred Date: Sat, 8 Mar 1997 23:38:55 +0000 Subject: [PATCH] lilypond-0.0.40 --- flower/lib/include/pqueue.hh | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/flower/lib/include/pqueue.hh b/flower/lib/include/pqueue.hh index 195232317e..c8dfe1bea6 100644 --- a/flower/lib/include/pqueue.hh +++ b/flower/lib/include/pqueue.hh @@ -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 */ template @@ -22,23 +24,47 @@ struct PQueue { Array value_arr_; Array 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; } -- 2.39.5