]> git.donarmstrong.com Git - lilypond.git/commitdiff
flower-1.1.2
authorfred <fred>
Sun, 23 Feb 1997 23:34:23 +0000 (23:34 +0000)
committerfred <fred>
Sun, 23 Feb 1997 23:34:23 +0000 (23:34 +0000)
flower/pqueue.hh [new file with mode: 0644]

diff --git a/flower/pqueue.hh b/flower/pqueue.hh
new file mode 100644 (file)
index 0000000..1952323
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+  pqueue.hh -- declare 
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef PQUEUE_HH
+#define PQUEUE_HH
+
+#include "varray.hh"
+
+/**
+  Stupid Prioq. Should use Lists and STL.
+  Smallest is put at the front.
+ */
+
+template<class V, class I>
+struct PQueue
+{
+    Array<V> value_arr_;
+    Array<I> 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