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)
/*
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>
*/
#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);
}
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);
void
Note_column::sort()
{
- head_l_arr_.sort( Notehead::compare);
+ head_l_arr_.sort( Note_head::compare);
}
Interval_t<int>
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;
+ }
+}
/*
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);
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);
+ }
+}