]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.65
authorfred <fred>
Sun, 24 Mar 2002 19:44:22 +0000 (19:44 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:44:22 +0000 (19:44 +0000)
flower/include/parray.hh
lily/note-column.cc
lily/rest-column.cc

index e003d462231a1808b6b2327c76aa63ad317449d3..1e7404ee5565edf2c34f9157700712288a677670 100644 (file)
   an array of pointers.
 
   TODO
-  should init to 0.
+  should init to 0. Derive from Array<void*>? 
  */
 template<class T>
-class Link_array : public Array<T>
+class Link_array : public Array<T*>
 {
+    static default_compare(T *const& p1, T  *const&p2) {
+       /* can't do p1 -p2, since T might be an incomplete type */
+       if (p1 < p2)
+           return -1 ;
+       if (p2 < p1)
+           return 1;
+       return 0;
+    }
 public:
-    int find_i (T t) const{
+    void substitute(T *old, T*new_l)
+    {
+       int i;
+       while ((i = find_i(old)) >=0) 
+           if (new_l)
+               elem(i) =new_l;
+           else
+               del(i);
+    }
+    void default_sort() {
+       sort(default_compare);
+    }
+    void uniq() {
+       Link_array<T> l_arr;
+       for (int i=0; i < size(); i++) 
+           if (!i || elem(i-1) != elem(i))
+               l_arr.push(elem(i)); 
+       *this = l_arr;
+    }
+
+    int find_i (T const * t) const {
        for (int i=0; i < size(); i++)
            if (elem(i) == t)
                return i;
        return -1;
     }
-    T find_l(T t)const
+    T *find_l(T const *t)const
     {
        int i = find_i(t);
        if (i >= 0)
index f0c518a5b78fee195de4bcd86296352d3ff77a08..9af2cd3fd430c5d1aaa641907b86f286fdedcb23 100644 (file)
@@ -1,7 +1,7 @@
 /*
   note-column.cc -- implement Note_column
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
@@ -9,7 +9,7 @@
 #include "note-column.hh"
 #include "debug.hh"
 #include "script.hh"
-#include "notehead.hh"
+#include "note-head.hh"
 #include "stem.hh"
 
 IMPLEMENT_STATIC_NAME(Note_column);
@@ -22,7 +22,7 @@ Note_column::add(Stem*stem_l)
 }
 
 void
-Note_column::add(Notehead* n_l)
+Note_column::add(Note_head* n_l)
 {
     assert(!n_l->rest_b_);
     head_l_arr_.push(n_l);
@@ -39,7 +39,7 @@ Note_column::Note_column()
 void
 Note_column::sort()
 {
-    head_l_arr_.sort( Notehead::compare);
+    head_l_arr_.sort( Note_head::compare);
 }
     
 Interval_t<int>
@@ -62,3 +62,18 @@ Note_column::do_pre_processing()
            dir_i_ = (head_positions_interval().center() >=  5) ? -1 : 1;
     }
 }
+
+    
+
+void
+Note_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
+{
+    Script_column::do_substitute_dependency(o,n);
+    if (o->name() == Note_head::static_name()) {
+       head_l_arr_.substitute( (Note_head*)o->item(), 
+                               (n)? (Note_head*)n->item() : 0);
+    }
+    if (stem_l_ == o) {
+       stem_l_ = n ? (Stem*)n->item():0;
+    }
+}
index f9543a2e013e5976df74e5a155c38a9612dd010c..8d0963482abc49ab7be4d6ccdddd5a5801111a96 100644 (file)
@@ -1,17 +1,17 @@
 /*
   rest-column.cc -- implement Rest_column
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
 #include "rest-column.hh"
-#include "notehead.hh"
+#include "note-head.hh"
 #include "rest-column.hh"
 
 void
-Rest_column::add(Notehead *n_l)
+Rest_column::add(Note_head *n_l)
 {
     add_support(n_l);
     head_l_arr_.push(n_l);
@@ -31,3 +31,13 @@ Rest_column::Rest_column()
     dir_i_ = 0;
 }
     
+
+void
+Rest_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
+{
+    Script_column::do_substitute_dependency(o,n);
+    if (o->name() == Note_head::static_name()) {
+       head_l_arr_.substitute( (Note_head*)o->item(), 
+                               (n)? (Note_head*)n->item() : 0);
+    }
+}