- now_heads_.sort (&head_pitch_compare);
- /*
- We could sort stopped_heads_ as well (and use a linear alg. in
- stead of nested loop), but we'd have to use a stable sorting
- algorithm, since the ordering of the stopped heads (of the
- same pitch) is relevant.
- */
-
- SCM head_list = SCM_EOL;
-
- for (int i = now_heads_.size(); i--;)
- {
- for (int j = stopped_heads_.size(); j--;)
- {
- int comp
- = head_pitch_compare (now_heads_[i], stopped_heads_[j]);
-
- if (!comp)
- {
- head_list = gh_cons (gh_cons (stopped_heads_[j]->self_scm (),
- now_heads_[i]->self_scm ()),
- head_list);
-
- now_heads_.del (i);
- stopped_heads_.del (j);
- break ;
- }
- }
- }
-
- SCM basic = get_property ("Tie");
- SCM sparse = get_property ("sparseTies");
- if (to_boolean (sparse))
- {
- int i = scm_ilength (head_list);
-
- if (!i)
- return;
-
- SCM pair = scm_list_ref (head_list, gh_int2scm (i/2));
-
- Spanner * p = new Spanner (basic);
-
- Tie::set_interface (p); // cannot remove.
- Tie::set_head (p,LEFT, dynamic_cast<Item*> (unsmob_grob (ly_car (pair))));
- Tie::set_head (p,RIGHT, dynamic_cast<Item*> (unsmob_grob (ly_cdr (pair))));
-
- ties_.push (p);
- announce_grob(p, req_->self_scm());
- }
- else for (SCM s = head_list; gh_pair_p (s); s = ly_cdr (s))
- {
- Grob * p = new Spanner (basic);
- Tie::set_interface (p); // cannot remove yet!
-
- Tie::set_head (p, LEFT, dynamic_cast<Item*> (unsmob_grob (ly_caar (s))));
- Tie::set_head (p, RIGHT, dynamic_cast<Item*> (unsmob_grob (ly_cdar (s))));
-
- ties_.push (p);
- announce_grob(p, req_->self_scm());
- }
-
- if (ties_.size () > 1 && !tie_column_)
- {
- tie_column_ = new Spanner (get_property ("TieColumn"));
-
- for (int i = ties_.size (); i--;)
- Tie_column::add_tie (tie_column_,ties_ [i]);
- announce_grob(tie_column_, SCM_EOL);
- }