From: fred Date: Sun, 23 Feb 1997 23:34:23 +0000 (+0000) Subject: flower-1.1.2 X-Git-Tag: release/1.5.59~6302 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=409af0f4bce5196085effbae4a1a289ace18a810;p=lilypond.git flower-1.1.2 --- diff --git a/flower/pqueue.hh b/flower/pqueue.hh new file mode 100644 index 0000000000..195232317e --- /dev/null +++ b/flower/pqueue.hh @@ -0,0 +1,46 @@ +/* + pqueue.hh -- declare + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef PQUEUE_HH +#define PQUEUE_HH + +#include "varray.hh" + +/** + Stupid Prioq. Should use Lists and STL. + Smallest is put at the front. + */ + +template +struct PQueue +{ + Array value_arr_; + Array indices_arr_; + + 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); + } + int size() { return value_arr_.size(); } + V front_val() { return value_arr_[0]; } + I front_idx() { return indices_arr_[0]; } + V get() { + V retval = front_val(); + value_arr_.del(0); + indices_arr_.del(0); + return retval; + } + +}; +#endif // PQUEUE_HH