From 9d4a5bbc9687aef811a60aabd9cb839412984e96 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 3 Feb 2006 01:32:16 +0000 Subject: [PATCH] * flower/include/pqueue.hh: Derive from std::vector. * flower/include/parray.hh: Conform to std::vector interface. Update users. --- ChangeLog | 7 + flower/include/array.hh | 39 +++- flower/include/array.icc | 21 --- flower/include/flower-proto.hh | 4 +- flower/include/parray.hh | 118 +++++++++---- flower/include/pqueue.hh | 2 +- flower/include/std-string.hh | 2 +- flower/include/std-vector.hh | 216 ++++++++++++++++------- flower/test-std.cc | 41 ++++- lily/accidental-engraver.cc | 6 +- lily/accidental-placement.cc | 37 ++-- lily/align-interface.cc | 4 +- lily/ambitus.cc | 4 +- lily/audio-element-info.cc | 4 +- lily/auto-beam-engraver.cc | 4 +- lily/axis-group-interface-scheme.cc | 2 +- lily/axis-group-interface.cc | 4 +- lily/beam-concave.cc | 2 +- lily/beam-quanting.cc | 4 +- lily/break-algorithm.cc | 10 +- lily/break-align-interface.cc | 8 +- lily/break-substitution.cc | 8 +- lily/chord-name-engraver.cc | 2 +- lily/cluster-engraver.cc | 2 +- lily/cluster.cc | 4 +- lily/collision-engraver.cc | 2 +- lily/completion-note-heads-engraver.cc | 12 +- lily/context-def.cc | 8 +- lily/context.cc | 4 +- lily/custos-engraver.cc | 2 +- lily/dot-column-engraver.cc | 2 +- lily/dot-column.cc | 4 +- lily/drum-note-engraver.cc | 8 +- lily/drum-note-performer.cc | 7 +- lily/dynamic-engraver.cc | 4 +- lily/figured-bass-engraver.cc | 14 +- lily/fingering-engraver.cc | 4 +- lily/gourlay-breaking.cc | 6 +- lily/grid-line-span-engraver.cc | 2 +- lily/grob-array.cc | 6 +- lily/grob-info.cc | 4 +- lily/grob.cc | 2 +- lily/hara-kiri-group-spanner.cc | 2 +- lily/horizontal-bracket-engraver.cc | 10 +- lily/horizontal-bracket.cc | 2 +- lily/include/accidental-placement.hh | 4 +- lily/include/audio-column.hh | 4 +- lily/include/audio-element-info.hh | 4 +- lily/include/audio-staff.hh | 4 +- lily/include/axis-group-engraver.hh | 2 +- lily/include/axis-group-interface.hh | 4 +- lily/include/beam.hh | 2 +- lily/include/beaming.hh | 2 +- lily/include/book.hh | 2 +- lily/include/break-algorithm.hh | 6 +- lily/include/break-align-interface.hh | 2 +- lily/include/column-x-positions.hh | 6 +- lily/include/context-def.hh | 2 +- lily/include/context.hh | 2 +- lily/include/dimension-cache.hh | 2 +- lily/include/grob-array.hh | 12 +- lily/include/grob-info.hh | 4 +- lily/include/grob.hh | 2 +- lily/include/horizontal-bracket.hh | 2 +- lily/include/includable-lexer.hh | 4 +- lily/include/lily-parser.hh | 2 +- lily/include/lily-proto.hh | 48 +++++ lily/include/midi-walker.hh | 2 +- lily/include/note-collision.hh | 6 +- lily/include/paper-book.hh | 2 +- lily/include/paper-column-engraver.hh | 2 +- lily/include/performance.hh | 4 +- lily/include/pointer-group-interface.hh | 10 +- lily/include/score-engraver.hh | 2 +- lily/include/score.hh | 4 +- lily/include/separating-group-spanner.hh | 2 +- lily/include/simple-spacer.hh | 8 +- lily/include/slur-configuration.hh | 2 +- lily/include/slur-scoring.hh | 8 +- lily/include/source-file.hh | 5 +- lily/include/spacing-spanner.hh | 12 +- lily/include/spanner.hh | 2 +- lily/include/system.hh | 4 +- lily/include/tie-column-format.hh | 4 +- lily/include/tie-formatting-problem.hh | 8 +- lily/include/timing-translator.hh | 2 +- lily/include/translator-group.hh | 2 +- lily/include/tuplet-bracket.hh | 2 +- lily/keyword.cc | 3 +- lily/laissez-vibrer-engraver.cc | 2 +- lily/laissez-vibrer-tie-column.cc | 4 +- lily/lyric-performer.cc | 2 +- lily/multi-measure-rest-engraver.cc | 6 +- lily/new-fingering-engraver.cc | 2 +- lily/note-collision.cc | 21 +-- lily/note-heads-engraver.cc | 6 +- lily/note-name-engraver.cc | 4 +- lily/note-performer.cc | 7 +- lily/note-spacing.cc | 6 +- lily/output-property-engraver.cc | 2 +- lily/paper-column.cc | 2 +- lily/paper-score.cc | 2 +- lily/phrasing-slur-engraver.cc | 4 +- lily/piano-pedal-engraver.cc | 6 +- lily/piano-pedal-performer.cc | 2 +- lily/pitched-trill-engraver.cc | 2 +- lily/pointer-group-interface.cc | 10 +- lily/rest-collision-engraver.cc | 2 +- lily/rest-collision.cc | 8 +- lily/rhythmic-column-engraver.cc | 2 +- lily/script-column-engraver.cc | 2 +- lily/script-column.cc | 2 +- lily/separating-group-spanner.cc | 2 +- lily/separating-line-group-engraver.cc | 2 +- lily/simple-spacer.cc | 8 +- lily/slur-engraver.cc | 4 +- lily/slur-scoring.cc | 6 +- lily/source-file.cc | 2 +- lily/spacing-determine-loose-columns.cc | 8 +- lily/spacing-loose-columns.cc | 2 +- lily/spacing-spanner.cc | 8 +- lily/span-arpeggio-engraver.cc | 2 +- lily/span-bar-engraver.cc | 2 +- lily/spanner.cc | 14 +- lily/stanza-number-align-engraver.cc | 4 +- lily/stem.cc | 6 +- lily/system-start-delimiter-engraver.cc | 2 +- lily/system.cc | 18 +- lily/tab-note-heads-engraver.cc | 8 +- lily/text-engraver.cc | 4 +- lily/tie-column-format.cc | 2 +- lily/tie-column.cc | 4 +- lily/tie-engraver.cc | 4 +- lily/tie-formatting-problem.cc | 14 +- lily/tuplet-bracket.cc | 2 +- lily/tuplet-engraver.cc | 2 +- lily/vertical-align-engraver.cc | 5 +- 137 files changed, 674 insertions(+), 445 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d2b7f204b..0607738bb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-02-03 Jan Nieuwenhuizen + + * flower/include/pqueue.hh: Derive from std::vector. + + * flower/include/parray.hh: Conform to std::vector interface. + Update users. + 2006-02-02 Graham Percival * Documentation/topdocs/NEWS.itely: grammar fix from Laura. diff --git a/flower/include/array.hh b/flower/include/array.hh index c8110b1790..a881c778d4 100644 --- a/flower/include/array.hh +++ b/flower/include/array.hh @@ -3,13 +3,13 @@ Distributed under GNU GPL */ -#ifndef ARRAY_H -#define ARRAY_H - #ifndef STD_VECTOR_HH #error array.hh is obsolete, use std-vector.hh #endif +#ifndef ARRAY_H +#define ARRAY_H + #include using namespace std; @@ -273,10 +273,6 @@ public: return Tarray; } - T const *accesses () const - { - return array_; - } void operator = (Array const &src) { resize (src.size_); @@ -329,6 +325,35 @@ public: swap (v[i], v[j]); } + template + void + concat (Array &v, Array const& w) + { + v.insert (v.end (), w.begin (), w.end ()); + } + + template + void + vector_sort (Array &v, int (*compare) (T const &, T const &), + vsize lower=-1, vsize upper=-1) + { + if (lower < 0) + { + lower = 0; + upper = v.size () - 1; + } + if (lower >= upper) + return; + swap (v[lower], v[(lower + upper) / 2]); + vsize last = lower; + for (vsize i = lower +1; i <= upper; i++) + if (compare (v.array_[i], v.array_[lower]) < 0) + swap (v[++last], v[i]); + swap (v[lower], v[last]); + vector_sort (v, compare, lower, last - 1); + vector_sort (v, compare, last + 1, upper); + } + #include "array.icc" } diff --git a/flower/include/array.icc b/flower/include/array.icc index 560ec31c72..33f44a6778 100644 --- a/flower/include/array.icc +++ b/flower/include/array.icc @@ -37,27 +37,6 @@ arrcpy (T *dest, T const *src, vsize count) #endif } -template INLINE void -vector_sort (Array &v, int (*compare) (T const &, T const &), - vsize lower=-1, vsize upper=-1) -{ - if (lower < 0) - { - lower = 0; - upper = v.size () - 1; - } - if (lower >= upper) - return; - swap (v[lower], v[(lower + upper) / 2]); - vsize last = lower; - for (vsize i = lower +1; i <= upper; i++) - if (compare (v.array_[i], v.array_[lower]) < 0) - swap (v[++last], v[i]); - swap (v[lower], v[last]); - vector_sort (v, compare, lower, last - 1); - vector_sort (v, compare, last + 1, upper); -} - template INLINE void Array::OK () const diff --git a/flower/include/flower-proto.hh b/flower/include/flower-proto.hh index 66bd2648c1..650622eef9 100644 --- a/flower/include/flower-proto.hh +++ b/flower/include/flower-proto.hh @@ -18,6 +18,8 @@ typedef unsigned char Byte; namespace std { struct String_data; struct String_handle; + //template struct Array; + template struct Link_array; } struct String_convert; @@ -25,8 +27,6 @@ struct String_convert; #include "std-vector.hh" #include "real.hh" -//template struct Array; -template struct Link_array; template struct Link_list; template struct Interval_t; template struct PQueue; diff --git a/flower/include/parray.hh b/flower/include/parray.hh index 2e90dd7c78..64556ec4e2 100644 --- a/flower/include/parray.hh +++ b/flower/include/parray.hh @@ -9,8 +9,13 @@ #ifndef PARRAY_HH #define PARRAY_HH -#include "std-vector.hh" +#ifndef STD_VECTOR_HH +#error array.hh is obsolete, use std-vector.hh +#endif +using namespace std; + +namespace std { /** an array of pointers. @@ -42,6 +47,7 @@ public: } Array::begin; + Array::data; Array::end; Array::clear; Array::erase; @@ -74,6 +80,15 @@ public: { } + /* std::vector interface */ + //typedef T** iterator; + //typedef T* const* iterator_const; + + Link_array (const_iterator begin, const_iterator end) + : Array (begin, end) + { + } + T *at (int i) { return (T *) Array::at (i); @@ -174,10 +189,18 @@ public: return at (i); } - T ** accesses () const + T ** + data () { - return (T **) Array::accesses (); + return (T**) Array::data (); } + + T * const* + data () const + { + return (T**) Array::data (); + } + /** remove i-th element, and return it. */ @@ -266,42 +289,10 @@ junk_pointers (Link_array &a) a.clear (); } -/* - lookup with binsearch, return tokencode. -*/ template int -binsearch (Array const &arr, T t, int (*compare) (T const &, T const &)) -{ - int cmp; - int result; - int lo = 0; - int hi = arr.size (); - - /* binary search */ - do - { - cmp = (lo + hi) / 2; - - result = compare (t, arr[cmp]); - - if (result < 0) - hi = cmp; - else - lo = cmp; - } - while (hi - lo > 1); - - if (!compare (t, arr[lo])) - return lo; - /* not found */ - return -1; -} - -template -int -binsearch_links (Link_array const &arr, T *t, - int (*compare) (T *const &, T *const &)) +binary_search (Link_array const &arr, T *t, + int (*compare) (T *const &, T *const &)) { int cmp; int result; @@ -356,6 +347,59 @@ binary_search_bounds (Link_array const &table, while (*hi - *lo > 1); } +template +void +reverse (Link_array &v) +{ + vsize h = v.size () / 2; + for (vsize i = 0, j = v.size () - 1; i < h; i++, j--) + swap (v[i], v[j]); +} + +template +void +concat (Link_array &v, Link_array const& w) +{ + v.insert (v.end (), w.begin (), w.end ()); +} + +template +void +vector_sort (Link_array &v, int (*compare) (T *const &, T * const &), + vsize lower=-1, vsize upper=-1) +{ + if (lower < 0) + { + lower = 0; + upper = v.size () - 1; + } + if (lower >= upper) + return; + swap (v[lower], v[(lower + upper) / 2]); + vsize last = lower; + for (vsize i = lower +1; i <= upper; i++) + if (compare (v[i], v[lower]) < 0) + swap (v[++last], v[i]); + swap (v[lower], v[last]); + vector_sort (v, compare, lower, last - 1); + vector_sort (v, compare, last + 1, upper); +} + +template +void +uniq (Link_array &v) +{ + v.uniq (); +} + +template +typename Array::const_iterator +find (Link_array const &v, T * const& key) +{ + return v.begin () + v.find_index (key); +} + +} #endif // PARRAY_HH diff --git a/flower/include/pqueue.hh b/flower/include/pqueue.hh index 2f1896f42a..17d45f32b5 100644 --- a/flower/include/pqueue.hh +++ b/flower/include/pqueue.hh @@ -34,7 +34,7 @@ int compare (PQueue_ent const &e1, PQueue_ent const &e2) template class PQueue { - Array heap_array_; + std::vector heap_array_; T &elt (vsize i) { return heap_array_[i - 1]; diff --git a/flower/include/std-string.hh b/flower/include/std-string.hh index 53b02c2cca..7d2ae6d7cc 100644 --- a/flower/include/std-string.hh +++ b/flower/include/std-string.hh @@ -48,7 +48,7 @@ namespace std { #include "string.hh" -#endif /* STD_STRING */ +#endif /* ! STD_STRING */ namespace std { diff --git a/flower/include/std-vector.hh b/flower/include/std-vector.hh index 3386ac74b8..3fa220184e 100644 --- a/flower/include/std-vector.hh +++ b/flower/include/std-vector.hh @@ -9,7 +9,35 @@ #ifndef STD_VECTOR_HH #define STD_VECTOR_HH -#include // reverse, sort +#include /* find, reverse, sort */ +#include /* unary_function */ +#include + +#if HAVE_BOOST_LAMBDA +#include +#endif + +template +int default_compare (T const &a, T const &b) +{ + if (a < b) + return -1; + else if (a > b) + return 1; + else + return 0; +} + +template +int default_compare (T *const &a, T *const &b) +{ + if (a < b) + return -1; + else if (a > b) + return 1; + else + return 0; +} #if !STD_VECTOR /* Also declare vector, in the wrong way. */ @@ -18,7 +46,6 @@ #include #endif - #include "compare.hh" #if STD_VECTOR @@ -62,22 +89,14 @@ namespace std { { return v[v.size () - i - 1]; } - -#if 0 + template - vsize - // binary_search (std::vector const &v, - binary_search (vector const &v, - T const &key, int (*compare) (T const &, T const &), - vsize b=0, vsize e=VPOS) + void + concat (vector &v, vector const& w) { - //(void) compare; - typename vector::const_iterator i = find (v.iter (b), v.iter (e), key); - if (i != v.end ()) - return i - v.begin (); - return VPOS; + v.insert (v.end (), w.begin (), w.end ()); } -#else // c&p from array.icc; cannot easily use stl_algo:find b.o. compare func. + template void binary_search_bounds (vector const &table, @@ -85,6 +104,9 @@ namespace std { vsize *lo, vsize *hi) { + if (*lo >= *hi) + return; + int cmp; int result; @@ -104,15 +126,62 @@ namespace std { } template + void + binary_search_bounds (vector const &table, + T const *key, int (*compare) (T *const &, T *const &), + int *lo, + int *hi) + { + int cmp; + int result; + + /* binary search */ + do + { + cmp = (*lo + *hi) / 2; + + result = (*compare) ((T *) key, table[cmp]); + + if (result < 0) + *hi = cmp; + else + *lo = cmp; + } + while (*hi - *lo > 1); + } + +#if 0 + template vsize - binary_search (vector const &table, + // binary_search (std::vector const &v, + binary_search (vector const &v, T const &key, int (*compare) (T const &, T const &), + vsize b=0, vsize e=VPOS) + { + //(void) compare; + if (e == VPOS) + e = v.size (); + typename vector::const_iterator i = find (v.begin () + b, + v.begin () + e, key); + if (i != v.end ()) + return i - v.begin (); + return VPOS; + } +#else // c&p from array.icc; cannot easily use stl_algo:find b.o. compare func. + template + vsize + binary_search (vector const &table, + T const &key, + int (*compare) (T const &, T const &), vsize lo=0, vsize hi=VPOS) { if (hi == VPOS) hi = table.size (); + if (lo >= hi) + return VPOS; + binary_search_bounds (table, key, compare, &lo, &hi); if (! (*compare) (key, table[lo])) @@ -121,11 +190,13 @@ namespace std { /* not found */ return VPOS; } + + #endif #if 0 - /* FIXME: the simple test works, but lily barfs. */ + /* FIXME: the COMPARE functionality is broken? */ template void vector_sort (vector &v, int (*compare) (T const &, T const &), @@ -142,37 +213,29 @@ namespace std { } #else - template - void - swap (T *a, T *b) - { - T t = *a; - *a = *b; - *b = t; - } - // ugh, c&p -template void -vector_sort (vector &v, int (*compare) (T const &, T const &), - vsize lower=VPOS, vsize upper=VPOS) -{ - if (lower == VPOS) - { - lower = 0; - upper = v.size () - 1; + template void + vector_sort (vector &v, int (*compare) (T const &, T const &), + vsize lower=VPOS, vsize upper=VPOS) + { + if (lower == VPOS) + { + lower = 0; + upper = v.size () - 1; } - if (upper == VPOS || lower >= upper) - return; - swap (v[lower], v[(lower + upper) / 2]); - vsize last = lower; - for (vsize i = lower +1; i <= upper; i++) - if (compare (v[i], v[lower]) < 0) - swap (v[++last], v[i]); - swap (v[lower], v[last]); - vector_sort (v, compare, lower, last - 1); - vector_sort (v, compare, last + 1, upper); -} - + if (upper == VPOS || lower >= upper) + return; + swap (v[lower], v[(lower + upper) / 2]); + vsize last = lower; + for (vsize i = lower +1; i <= upper; i++) + if (compare (v[i], v[lower]) < 0) + swap (v[++last], v[i]); + swap (v[lower], v[last]); + vector_sort (v, compare, lower, last - 1); + vector_sort (v, compare, last + 1, upper); + } +#endif + template void reverse (vector &v) @@ -182,11 +245,52 @@ vector_sort (vector &v, int (*compare) (T const &, T const &), ::std::reverse (v.begin (), v.end ()); } -#endif + template + void + uniq (vector &v) + { + v.erase (unique (v.begin (), v.end ()), v.end ()); + } -} + template + typename vector::const_iterator + find (vector const &v, T const &key) + { + return ::std::find (v.begin (), v.end (), key); + } + +#if HAVE_BOOST_LAMBDA +#include + using namespace boost::lambda; + template + void + junk_pointers (vector &v) + { + for_each (v.begin (), v.end (), (delete _1, _1 = 0)); + v.clear (); + } +#else + + template struct del : public unary_function + { + void operator() (T x) + { + delete x; + x = 0; + } + }; + template + void + junk_pointers (vector &v) + { + // Hmm. + ::std::for_each (v.begin (), v.end (), del ()); + v.clear (); + } +#endif /* HAVE_BOOST_LAMBDA */ +} #else /* ! STD_VECTOR */ @@ -206,21 +310,11 @@ namespace std { } - #endif /* STD_VECTOR */ -template -int default_compare (T const &a, T const &b) -{ - if (a < b) - return -1; - else if (a > b) - return 1; - else - return 0; -} - - #include "array.hh" +#include "parray.hh" + +using namespace std; #endif /* STD_VECTOR_HH */ diff --git a/flower/test-std.cc b/flower/test-std.cc index 7e7acee091..6e53f987ad 100644 --- a/flower/test-std.cc +++ b/flower/test-std.cc @@ -1,10 +1,11 @@ + + #if !STD_VECTOR #define Array flower_vector #endif +#define HAVE_BOOST_LAMBDA 1 #include "std-vector.hh" -#include "parray.hh" - #include #include @@ -16,6 +17,8 @@ using boost::unit_test::test_suite; #define vector flower_vector #endif +using namespace std; + template void print (vector v) @@ -25,6 +28,7 @@ print (vector v) cout << endl; } +#if !STD_VECTOR template void print (Link_array v) @@ -33,7 +37,7 @@ print (Link_array v) cout << "v[" << i << "] = " << *v[i] << endl; cout << endl; } - +#endif BOOST_AUTO_UNIT_TEST (vector_erase) { @@ -114,7 +118,7 @@ BOOST_AUTO_UNIT_TEST (vector_insert) BOOST_AUTO_UNIT_TEST (parray_concat) { -#if 1 +#if !STD_VECTOR Link_array u, v; #else vector u, v; @@ -125,14 +129,14 @@ BOOST_AUTO_UNIT_TEST (parray_concat) u.push_back (&a[2]); v.push_back (&a[3]); v.push_back (&a[4]); - u.concat (v); + concat (u, v); BOOST_CHECK_EQUAL (u[0], &a[0]); BOOST_CHECK_EQUAL (u[1], &a[1]); BOOST_CHECK_EQUAL (u[2], &a[2]); BOOST_CHECK_EQUAL (u[3], &a[3]); BOOST_CHECK_EQUAL (u[4], &a[4]); BOOST_CHECK_EQUAL (u.size (), vsize (5)); - u.concat (v); + concat (u, v); BOOST_CHECK_EQUAL (u.size (), vsize (7)); u.clear (); @@ -142,7 +146,7 @@ BOOST_AUTO_UNIT_TEST (parray_concat) v.push_back (&a[2]); v.push_back (&a[3]); v.push_back (&a[4]); - u.concat (v); + concat (u, v); BOOST_CHECK_EQUAL (u[0], &a[0]); BOOST_CHECK_EQUAL (u[1], &a[1]); BOOST_CHECK_EQUAL (u[2], &a[2]); @@ -151,6 +155,27 @@ BOOST_AUTO_UNIT_TEST (parray_concat) BOOST_CHECK_EQUAL (u.size (), vsize (5)); } +BOOST_AUTO_UNIT_TEST (parray_uniq) +{ + vector v; + v.push_back (0); + v.push_back (1); + v.push_back (0); + vector_sort (v, default_compare); + uniq (v); + BOOST_CHECK_EQUAL (v.size (), vsize (2)); +} + +BOOST_AUTO_UNIT_TEST (vector_search) +{ + vector v; + v.push_back (0); + v.push_back (1); + v.push_back (2); + vsize i = binary_search (v, 1, &default_compare); + BOOST_CHECK_EQUAL (i, vsize (1)); +} + test_suite* init_unit_test_suite (int, char**) { @@ -160,5 +185,7 @@ init_unit_test_suite (int, char**) test->add (BOOST_TEST_CASE (vector_sorting)); test->add (BOOST_TEST_CASE (vector_insert)); test->add (BOOST_TEST_CASE (parray_concat)); + test->add (BOOST_TEST_CASE (parray_uniq)); + test->add (BOOST_TEST_CASE (vector_search)); return test; } diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index b240dfa032..bdd704da42 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -77,13 +77,13 @@ public: to store all information before we can really create the accidentals. */ - Link_array left_objects_; - Link_array right_objects_; + std::vector left_objects_; + std::vector right_objects_; Grob *accidental_placement_; std::vector accidentals_; - Link_array ties_; + std::vector ties_; }; /* diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index d35089066e..f800047988 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -57,8 +57,8 @@ Accidental_placement::add_accidental (Grob *me, Grob *a) */ void Accidental_placement::split_accidentals (Grob *accs, - Link_array *break_reminder, - Link_array *real_acc) + Link_array__Grob_ *break_reminder, + Link_array__Grob_ *real_acc) { for (SCM acs = accs->get_object ("accidental-grobs"); scm_is_pair (acs); acs = scm_cdr (acs)) @@ -82,11 +82,11 @@ Accidental_placement::get_relevant_accidental_extent (Grob *me, Item *item_col, Grob *left_object) { - Link_array br, ra; - Link_array *which = 0; + Link_array__Grob_ br, ra; + Link_array__Grob_ *which = 0; Accidental_placement::split_accidentals (me, &br, &ra); - br.concat (ra); + concat (br, ra); if (dynamic_cast (left_object)->break_status_dir () == RIGHT) which = &br; @@ -112,7 +112,7 @@ struct Accidental_placement_entry std::vector right_skyline_; Interval vertical_extent_; std::vector extents_; - Link_array grobs_; + Link_array__Grob_ grobs_; Real offset_; int notename_; Accidental_placement_entry () @@ -149,11 +149,11 @@ int ape_rcompare (Accidental_placement_entry *const &a, placement */ void -stagger_apes (Link_array *apes) +stagger_apes (Link_array__Accidental_placement_entry_ *apes) { - Link_array asc = *apes; + Link_array__Accidental_placement_entry_ asc = *apes; - asc.sort (&ape_compare); + vector_sort (asc, &ape_compare); apes->clear (); @@ -162,7 +162,10 @@ stagger_apes (Link_array *apes) { Accidental_placement_entry *a = 0; if (parity) - a = asc.pop (); + { + a = asc.back (); + asc.pop_back (); + } else a = asc[i++]; @@ -170,7 +173,7 @@ stagger_apes (Link_array *apes) parity = !parity; } - apes->reverse (); + reverse (*apes); } /* @@ -230,7 +233,7 @@ Accidental_placement::calc_positioning_done (SCM smob) TODO: there is a bug in this code. If two accs are on the same Y-position, they share an Ape, and will be printed in overstrike. */ - Link_array apes; + Link_array__Accidental_placement_entry_ apes; for (SCM s = accs; scm_is_pair (s); s = scm_cdr (s)) { Accidental_placement_entry *ape = new Accidental_placement_entry; @@ -248,7 +251,7 @@ Accidental_placement::calc_positioning_done (SCM smob) First we must extract *all* pointers. We can only determine extents if we're sure that we've found the right common refpoint */ - Link_array note_cols, heads; + Link_array__Grob_ note_cols, heads; for (vsize i = apes.size (); i--;) { Accidental_placement_entry *ape = apes[i]; @@ -282,15 +285,15 @@ Accidental_placement::calc_positioning_done (SCM smob) { extract_grob_set (c, "elements", gs); - note_cols.concat (gs); + concat (note_cols, gs); } } for (vsize i = note_cols.size (); i--;) - heads.concat (extract_grob_array (note_cols[i], "note-heads")); + concat (heads, extract_grob_array (note_cols[i], "note-heads")); - heads.default_sort (); - heads.uniq (); + vector_sort (heads, default_compare); + uniq (heads); common[Y_AXIS] = common_refpoint_of_array (heads, common[Y_AXIS], Y_AXIS); for (vsize i = apes.size (); i--;) diff --git a/lily/align-interface.cc b/lily/align-interface.cc index 2355ce11f4..26d8d81143 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -88,7 +88,7 @@ Align_interface::align_to_fixed_distance (Grob *me, Axis a) extract_grob_set (me, "elements", elem_source); - Link_array elems (elem_source); // writable.. + Link_array__Grob_ elems (elem_source); // writable.. Real where_f = 0; @@ -160,7 +160,7 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) Interval (0, Interval::infinity ())); std::vector dims; - Link_array elems; + Link_array__Grob_ elems; extract_grob_set (me, "elements", all_grobs); for (vsize i = 0; i < all_grobs.size (); i++) diff --git a/lily/ambitus.cc b/lily/ambitus.cc index 702d8ba7b5..bdab636b6f 100644 --- a/lily/ambitus.cc +++ b/lily/ambitus.cc @@ -30,7 +30,9 @@ Ambitus::print (SCM smob) && heads.size () > 1) { Grob *common - = common_refpoint_of_array (heads.slice (0, 2), me, Y_AXIS); + = common_refpoint_of_array (Link_array__Grob_ (heads.begin (), + heads.begin () + 2), + me, Y_AXIS); Grob *minh = heads[0]; Grob *maxh = heads[1]; diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index 75c24d96f3..edc322a052 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -25,11 +25,11 @@ Audio_element_info::Audio_element_info () origin_trans_ = 0; } -Link_array +Link_array__Context_ Audio_element_info::origin_contexts (Translator *end) const { Context *t = origin_trans_->context (); - Link_array r; + Link_array__Context_ r; do { r.push_back (t); diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index f6ed06283b..b7a9269057 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -56,7 +56,7 @@ private: */ Moment shortest_mom_; Spanner *finished_beam_; - Link_array *stems_; + Link_array__Item_ *stems_; int process_acknowledged_count_; Moment last_add_mom_; @@ -210,7 +210,7 @@ Auto_beam_engraver::begin_beam () return; } - stems_ = new Link_array; + stems_ = new Link_array__Item_; grouping_ = new Beaming_info_list; beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam")); diff --git a/lily/axis-group-interface-scheme.cc b/lily/axis-group-interface-scheme.cc index f5c7fb1529..8a672ea94f 100644 --- a/lily/axis-group-interface-scheme.cc +++ b/lily/axis-group-interface-scheme.cc @@ -22,7 +22,7 @@ LY_DEFINE (ly_relative_group_extent, "ly:relative-group-extent", SCM_ASSERT_TYPE (unsmob_grob (common), common, SCM_ARG2, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); - Link_array elts; + Link_array__Grob_ elts; if (!ga) { for (SCM s = elements; scm_is_pair (s); s = scm_cdr (s)) diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 112dc3d767..a994a2b321 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -45,7 +45,7 @@ Axis_group_interface::has_axis (Grob *me, Axis a) } Interval -Axis_group_interface::relative_group_extent (Link_array const &elts, +Axis_group_interface::relative_group_extent (Link_array__Grob_ const &elts, Grob *common, Axis a) { Interval r; @@ -88,7 +88,7 @@ Axis_group_interface::generic_group_extent (Grob *me, Axis a) } void -Axis_group_interface::get_children (Grob *me, Link_array *found) +Axis_group_interface::get_children (Grob *me, Link_array__Grob_ *found) { found->push_back (me); diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc index 81581bc66b..1b55e94004 100644 --- a/lily/beam-concave.cc +++ b/lily/beam-concave.cc @@ -87,7 +87,7 @@ Beam::calc_concaveness (SCM smob) { Grob *me = unsmob_grob (smob); - Link_array stems + Link_array__Grob_ stems = extract_grob_array (me, "stems"); if (is_knee (me)) diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index 5b9b2dbaed..90e0bb7cde 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -139,7 +139,7 @@ Beam::quanting (SCM smob, SCM posns) Do stem computations. These depend on YL and YR linearly, so we can precompute for every stem 2 factors. */ - Link_array stems + Link_array__Grob_ stems = extract_grob_array (me, "stems"); std::vector stem_infos; std::vector base_lengths; @@ -327,7 +327,7 @@ Beam::quanting (SCM smob, SCM posns) } Real -Beam::score_stem_lengths (Link_array const &stems, +Beam::score_stem_lengths (Link_array__Grob_ const &stems, std::vector const &stem_infos, std::vector const &base_stem_ys, std::vector const &stem_xs, diff --git a/lily/break-algorithm.cc b/lily/break-algorithm.cc index 662ae54d1b..bfc5da52fb 100644 --- a/lily/break-algorithm.cc +++ b/lily/break-algorithm.cc @@ -18,7 +18,7 @@ std::vector Break_algorithm::find_break_indices () const { - Link_array all = pscore_->root_system ()->columns (); + Link_array__Grob_ all = pscore_->root_system ()->columns (); std::vector retval; for (vsize i = 0; i < all.size (); i++) @@ -32,11 +32,11 @@ Break_algorithm::find_break_indices () const return retval; } -Link_array +Link_array__Grob_ Break_algorithm::find_breaks () const { - Link_array all = pscore_->root_system ()->columns (); - Link_array retval; + Link_array__Grob_ all = pscore_->root_system ()->columns (); + Link_array__Grob_ retval; for (vsize i = 0; i < all.size (); i++) if (Item::is_breakable (all[i])) @@ -50,7 +50,7 @@ Break_algorithm::find_breaks () const } Simple_spacer_wrapper * -Break_algorithm::generate_spacing_problem (Link_array const &curline, +Break_algorithm::generate_spacing_problem (Link_array__Grob_ const &curline, Interval line) const { Simple_spacer_wrapper *spw = new Simple_spacer_wrapper; diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index ac5cfa33f3..854d2778ed 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -45,7 +45,7 @@ Break_align_interface::self_align_callback (SCM smob) So we return the correct order as an array. */ -Link_array +Link_array__Grob_ Break_align_interface::ordered_elements (Grob *grob) { Item *me = dynamic_cast (grob); @@ -56,14 +56,14 @@ Break_align_interface::ordered_elements (Grob *grob) || scm_c_vector_length (order_vec) < 3) return elts; - Link_array writable_elts (elts); + Link_array__Grob_ writable_elts (elts); SCM order = scm_vector_ref (order_vec, scm_from_int (me->break_status_dir () + 1)); /* Copy in order specified in BREAK-ALIGN-ORDER. */ - Link_array new_elts; + Link_array__Grob_ new_elts; for (; scm_is_pair (order); order = scm_cdr (order)) { SCM sym = scm_car (order); @@ -95,7 +95,7 @@ Break_align_interface::calc_positioning_done (SCM smob) Grob *grob = unsmob_grob (smob); Item *me = dynamic_cast (grob); - Link_array elems = ordered_elements (me); + Link_array__Grob_ elems = ordered_elements (me); std::vector extents; int last_nonempty = -1; diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index d14092876f..2c822f8548 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -139,17 +139,17 @@ do_break_substitution (SCM src) /* Perform substitution on GROB_LIST using a constant amount of stack. */ -Link_array temporary_substition_array; +Link_array__Grob_ temporary_substition_array; void substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr) { - Link_array &old_grobs (grob_arr->array_reference ()); - Link_array *new_grobs (new_arr == grob_arr + Link_array__Grob_ &old_grobs (grob_arr->array_reference ()); + Link_array__Grob_ *new_grobs (new_arr == grob_arr ? & temporary_substition_array : &new_arr->array_reference ()); new_grobs->resize (old_grobs.size ()); - Grob **array = (Grob **) new_grobs->accesses (); + Grob **array = (Grob **) new_grobs->data (); Grob **ptr = array; for (vsize i = 0; i < old_grobs.size (); i++) { diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index e079e982c0..a5da925e60 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -31,7 +31,7 @@ private: void add_note (Music *); Item *chord_name_; - Link_array notes_; + Link_array__Music_ notes_; SCM last_chord_; }; diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index 8291736944..d564a2bdfc 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -24,7 +24,7 @@ protected: void stop_translation_timestep (); virtual void finalize (); private: - Link_array cluster_notes_; + Link_array__Music_ cluster_notes_; Item *beacon_; void typeset_grobs (); diff --git a/lily/cluster.cc b/lily/cluster.cc index cefb02f782..a9ac17408a 100644 --- a/lily/cluster.cc +++ b/lily/cluster.cc @@ -133,7 +133,7 @@ Cluster::print (SCM smob) Grob *commonx = left_bound->common_refpoint (right_bound, X_AXIS); - Link_array const &cols = extract_grob_array (me, "columns"); + Link_array__Grob_ const &cols = extract_grob_array (me, "columns"); if (cols.empty ()) { me->warning (_ ("junking empty cluster")); @@ -175,7 +175,7 @@ Cluster::print (SCM smob) if (spanner->get_break_index () < orig->broken_intos_.size () - 1) { Spanner *next = orig->broken_intos_[spanner->get_break_index () + 1]; - Link_array const &next_cols = extract_grob_array (next, "columns"); + Link_array__Grob_ const &next_cols = extract_grob_array (next, "columns"); if (next_cols.size () > 0) { Grob *next_commony = common_refpoint_of_array (next_cols, next, Y_AXIS); diff --git a/lily/collision-engraver.cc b/lily/collision-engraver.cc index 285dd90820..1bdd960968 100644 --- a/lily/collision-engraver.cc +++ b/lily/collision-engraver.cc @@ -14,7 +14,7 @@ class Collision_engraver : public Engraver { Item *col_; - Link_array note_columns_; + Link_array__Grob_ note_columns_; protected: DECLARE_ACKNOWLEDGER (note_column); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 7bdf2e3ba5..af0cb783f9 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -43,13 +43,13 @@ using namespace std; class Completion_heads_engraver : public Engraver { - Link_array notes_; - Link_array prev_notes_; - Link_array ties_; + Link_array__Item_ notes_; + Link_array__Item_ prev_notes_; + Link_array__Grob_ ties_; - Link_array dots_; - Link_array note_events_; - Link_array scratch_note_events_; + Link_array__Item_ dots_; + Link_array__Music_ note_events_; + Link_array__Music_ scratch_note_events_; Moment note_end_mom_; bool is_first_; diff --git a/lily/context-def.cc b/lily/context-def.cc index 906a42eb41..80663c9185 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -192,20 +192,20 @@ Context_def::get_default_child (SCM user_mod) const return name; } -Link_array +Link_array__Context_def_ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const { assert (scm_is_symbol (type_sym)); SCM accepted = get_accepted (SCM_EOL); - Link_array accepteds; + Link_array__Context_def_ accepteds; for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s)) if (Context_def *t = unsmob_context_def (find_context_def (odef, scm_car (s)))) accepteds.push_back (t); - Link_array best_result; + Link_array__Context_def_ best_result; for (vsize i = 0; i < accepteds.size (); i++) { /* do not check aliases, because \context Staff should not @@ -222,7 +222,7 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const { Context_def *g = accepteds[i]; - Link_array result + Link_array__Context_def_ result = g->path_to_acceptable_context (type_sym, odef); if (result.size () && result.size () < best_depth) { diff --git a/lily/context.cc b/lily/context.cc index 405dc4b5d4..0fbdc20731 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -124,7 +124,7 @@ Context::create_unique_context (SCM n, SCM operations) /* TODO: use accepts_list_. */ - Link_array path + Link_array__Context_def_ path = unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ()); if (path.size ()) @@ -182,7 +182,7 @@ Context::find_create_context (SCM n, std::string id, SCM operations) /* TODO: use accepts_list_. */ - Link_array path + Link_array__Context_def_ path = unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ()); if (path.size ()) diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index 53f24a6f7c..b68ed60388 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -37,7 +37,7 @@ public: private: Item *create_custos (); bool custos_permitted_; - Link_array custodes_; + Link_array__Grob_ custodes_; std::vector pitches_; }; diff --git a/lily/dot-column-engraver.cc b/lily/dot-column-engraver.cc index a157b6a715..f5c4a8ad95 100644 --- a/lily/dot-column-engraver.cc +++ b/lily/dot-column-engraver.cc @@ -17,7 +17,7 @@ class Dot_column_engraver : public Engraver { Grob *dotcol_; Grob *stem_; - Link_array heads_; + Link_array__Item_ heads_; public: TRANSLATOR_DECLARATIONS (Dot_column_engraver); diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 84f56b6418..f3e2af55f9 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -204,7 +204,7 @@ SCM Dot_column::calc_positioning_done (SCM smob) { Grob *me = unsmob_grob (smob); - Link_array dots + Link_array__Grob_ dots = extract_grob_array (me, "dots"); { /* @@ -227,7 +227,7 @@ Dot_column::calc_positioning_done (SCM smob) } } - dots.sort (compare_position); + vector_sort (dots, &compare_position); for (vsize i = dots.size (); i--;) if (!dots[i]->is_live ()) dots.erase (dots.begin () + i); diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 4494e2c729..9293fc72bc 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -18,10 +18,10 @@ using namespace std; class Drum_notes_engraver : public Engraver { - Link_array notes_; - Link_array dots_; - Link_array scripts_; - Link_array events_; + Link_array__Item_ notes_; + Link_array__Item_ dots_; + Link_array__Item_ scripts_; + Link_array__Music_ events_; public: TRANSLATOR_DECLARATIONS (Drum_notes_engraver); diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index dd83e6699f..0dab3e2890 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -25,8 +25,8 @@ protected: void process_music (); private: - Link_array note_evs_; - Link_array notes_; + Link_array__Music_ note_evs_; + Link_array__Audio_note_ notes_; }; Drum_note_performer::Drum_note_performer () @@ -40,7 +40,8 @@ Drum_note_performer::process_music () while (note_evs_.size ()) { - Music *n = note_evs_.pop (); + Music *n = note_evs_.back (); + note_evs_.pop_back (); SCM sym = n->get_property ("drum-type"); SCM defn = SCM_EOL; diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index e6ecc2a972..3dcbea5ce6 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -55,8 +55,8 @@ class Dynamic_engraver : public Engraver Drul_array accepted_spanevents_drul_; - Link_array pending_columns_; - Link_array pending_elements_; + Link_array__Note_column_ pending_columns_; + Link_array__Grob_ pending_elements_; void typeset_all (); diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index ee5517e94b..8d97f2998d 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -63,12 +63,12 @@ struct Figured_bass_engraver : public Engraver void add_brackets (); void create_grobs (); - void center_continuations (Link_array const &consecutive_lines); + void center_continuations (Link_array__Spanner_ const &consecutive_lines); void center_repeated_continuations (); protected: std::vector groups_; Spanner *alignment_; - Link_array new_musics_; + Link_array__Music_ new_musics_; bool continuation_; bool new_music_found_; @@ -165,11 +165,11 @@ Figured_bass_engraver::try_music (Music *m) } void -Figured_bass_engraver::center_continuations (Link_array const &consecutive_lines) +Figured_bass_engraver::center_continuations (Link_array__Spanner_ const &consecutive_lines) { if (consecutive_lines.size () == 2) { - Link_array left_figs; + Link_array__Grob_ left_figs; for (vsize j = consecutive_lines.size(); j--;) left_figs.push_back (consecutive_lines[j]->get_bound (LEFT)); @@ -185,7 +185,7 @@ Figured_bass_engraver::center_continuations (Link_array const &consecut void Figured_bass_engraver::center_repeated_continuations () { - Link_array consecutive_lines; + Link_array__Spanner_ consecutive_lines; for (vsize i = 0; i <= groups_.size(); i++) { if (i < groups_.size () @@ -220,7 +220,7 @@ Figured_bass_engraver::clear_spanners () void Figured_bass_engraver::add_brackets () { - Link_array encompass; + Link_array__Grob_ encompass; bool inside = false; for (vsize i = 0; i < groups_.size (); i ++) { @@ -349,7 +349,7 @@ Figured_bass_engraver::process_music () /* Ugh, repeated code. */ - Link_array consecutive; + Link_array__Spanner_ consecutive; if (to_boolean (get_property ("figuredBassCenterContinuations"))) { for (vsize i = 0; i <= junk_continuations.size (); i++) diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index e45de84b14..daace643e4 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -15,8 +15,8 @@ class Fingering_engraver : public Engraver { - Link_array events_; - Link_array fingerings_; + Link_array__Music_ events_; + Link_array__Item_ fingerings_; public: TRANSLATOR_DECLARATIONS (Fingering_engraver); diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index f9ff08b6af..83f0006cb2 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -78,7 +78,7 @@ std::vector Gourlay_breaking::do_solve () const { std::vector optimal_paths; - Link_array all + Link_array__Grob_ all = pscore_->root_system ()->columns (); std::vector breaks = find_break_indices (); @@ -104,8 +104,8 @@ Gourlay_breaking::do_solve () const for (vsize start_idx = break_idx; start_idx--;) { - Link_array line = all.slice (breaks[start_idx], - breaks[break_idx] + 1); + Link_array__Grob_ line (all.begin () + breaks[start_idx], + all.begin () + breaks[break_idx] + 1); line[0] = dynamic_cast (line[0])->find_prebroken_piece (RIGHT); line.back () = dynamic_cast (line.back ())->find_prebroken_piece (LEFT); diff --git a/lily/grid-line-span-engraver.cc b/lily/grid-line-span-engraver.cc index b7daf45eac..742146402c 100644 --- a/lily/grid-line-span-engraver.cc +++ b/lily/grid-line-span-engraver.cc @@ -13,7 +13,7 @@ class Grid_line_span_engraver : public Engraver { Item *spanline_; - Link_array lines_; + Link_array__Item_ lines_; public: TRANSLATOR_DECLARATIONS (Grid_line_span_engraver); diff --git a/lily/grob-array.cc b/lily/grob-array.cc index ee1d3e78a2..99230a5ec3 100644 --- a/lily/grob-array.cc +++ b/lily/grob-array.cc @@ -29,13 +29,13 @@ Grob_array::Grob_array () ordered_ = false; } -Link_array & +Link_array__Grob_ & Grob_array::array_reference () { return grobs_; } -Link_array const & +Link_array__Grob_ const & Grob_array::array () const { return grobs_; @@ -89,7 +89,7 @@ Grob_array::empty () const } void -Grob_array::set_array (Link_array const &src) +Grob_array::set_array (Link_array__Grob_ const &src) { grobs_ = src; } diff --git a/lily/grob-info.cc b/lily/grob-info.cc index d8471d43f7..691d23b1a5 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -33,11 +33,11 @@ Grob_info::music_cause () const return unsmob_music (cause); } -Link_array +Link_array__Context_ Grob_info::origin_contexts (Translator *end) const { Context *t = origin_trans_->context (); - Link_array r; + Link_array__Context_ r; do { r.push_back (t); diff --git a/lily/grob.cc b/lily/grob.cc index c3905c4876..bde3c630af 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -608,7 +608,7 @@ common_refpoint_of_list (SCM elist, Grob *common, Axis a) } Grob * -common_refpoint_of_array (Link_array const &arr, Grob *common, Axis a) +common_refpoint_of_array (Link_array__Grob_ const &arr, Grob *common, Axis a) { for (vsize i = arr.size (); i--;) if (Grob *s = arr[i]) diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index f00434346d..1c5b92c054 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -43,7 +43,7 @@ Hara_kiri_group_spanner::consider_suicide (Grob *me) == 0)) return; - Link_array childs; + Link_array__Grob_ childs; Axis_group_interface::get_children (me, &childs); for (vsize i = 0; i < childs.size (); i++) childs[i]->suicide (); diff --git a/lily/horizontal-bracket-engraver.cc b/lily/horizontal-bracket-engraver.cc index 2babc2b033..52c828cffb 100644 --- a/lily/horizontal-bracket-engraver.cc +++ b/lily/horizontal-bracket-engraver.cc @@ -19,8 +19,8 @@ class Horizontal_bracket_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Horizontal_bracket_engraver); - Link_array bracket_stack_; - Link_array events_; + Link_array__Spanner_ bracket_stack_; + Link_array__Music_ events_; int pop_count_; int push_count_; @@ -106,10 +106,8 @@ void Horizontal_bracket_engraver::stop_translation_timestep () { for (int i = pop_count_; i--;) - { - if (bracket_stack_.size ()) - bracket_stack_.pop (); - } + if (bracket_stack_.size ()) + bracket_stack_.pop_back (); pop_count_ = 0; push_count_ = 0; } diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc index 652370a8eb..10d65316e0 100644 --- a/lily/horizontal-bracket.cc +++ b/lily/horizontal-bracket.cc @@ -47,7 +47,7 @@ Horizontal_bracket::make_bracket (Grob *me, Stencil Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint, - Link_array grobs, + Link_array__Grob_ grobs, Axis a, Direction dir) { Grob *common = common_refpoint_of_array (grobs, refpoint, a); diff --git a/lily/include/accidental-placement.hh b/lily/include/accidental-placement.hh index 27325ea6d8..bb6b681003 100644 --- a/lily/include/accidental-placement.hh +++ b/lily/include/accidental-placement.hh @@ -21,8 +21,8 @@ public: Item *item_col, Grob *acc); static void split_accidentals (Grob *accs, - Link_array *break_reminder, - Link_array *real_acc); + Link_array__Grob_ *break_reminder, + Link_array__Grob_ *real_acc); DECLARE_SCHEME_CALLBACK(calc_positioning_done, (SCM)); static bool has_interface (Grob *); diff --git a/lily/include/audio-column.hh b/lily/include/audio-column.hh index 3e514f0d3e..0bffa4e45e 100644 --- a/lily/include/audio-column.hh +++ b/lily/include/audio-column.hh @@ -9,7 +9,7 @@ #include "lily-proto.hh" #include "moment.hh" -#include "parray.hh" +#include "std-vector.hh" #include "audio-element.hh" /** @@ -24,7 +24,7 @@ public: void add_audio_item (Audio_item *i); Moment at_mom () const; - Link_array audio_items_; + Link_array__Audio_item_ audio_items_; private: Audio_column (Audio_column const &); diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh index 7b0b0fba72..915fac9c5a 100644 --- a/lily/include/audio-element-info.hh +++ b/lily/include/audio-element-info.hh @@ -10,7 +10,7 @@ #define AUDIO_ITEM_INFO_HH #include "lily-proto.hh" -#include "parray.hh" +#include "std-vector.hh" /** Data container for broadcasts @@ -22,7 +22,7 @@ public: Music *event_; Translator *origin_trans_; - Link_array origin_contexts (Translator *) const; + Link_array__Context_ origin_contexts (Translator *) const; Audio_element_info (Audio_element *, Music *); Audio_element_info (); diff --git a/lily/include/audio-staff.hh b/lily/include/audio-staff.hh index 6ba1155a41..d2a2baeba3 100644 --- a/lily/include/audio-staff.hh +++ b/lily/include/audio-staff.hh @@ -7,7 +7,7 @@ #ifndef AUDIO_STAFF_HH #define AUDIO_STAFF_HH -#include "parray.hh" +#include "std-vector.hh" #include "lily-proto.hh" #include "audio-element.hh" @@ -16,7 +16,7 @@ struct Audio_staff : public Audio_element void add_audio_item (Audio_item *l); void output (Midi_stream &midi_stream_r, int track_i); - Link_array audio_items_; + Link_array__Audio_item_ audio_items_; int channel_; }; diff --git a/lily/include/axis-group-engraver.hh b/lily/include/axis-group-engraver.hh index 998b84b5cb..535828577a 100644 --- a/lily/include/axis-group-engraver.hh +++ b/lily/include/axis-group-engraver.hh @@ -19,7 +19,7 @@ class Axis_group_engraver : public Engraver { protected: Spanner *staffline_; - Link_array elts_; + Link_array__Grob_ elts_; void process_music (); virtual void finalize (); DECLARE_ACKNOWLEDGER (grob); diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index 0898f3f8cd..04da19759d 100644 --- a/lily/include/axis-group-interface.hh +++ b/lily/include/axis-group-interface.hh @@ -19,13 +19,13 @@ struct Axis_group_interface static SCM generic_group_extent (Grob *me, Axis a); DECLARE_SCHEME_CALLBACK (width, (SCM smob)); DECLARE_SCHEME_CALLBACK (height, (SCM smob)); - static Interval relative_group_extent (Link_array const &list, + static Interval relative_group_extent (Link_array__Grob_ const &list, Grob *common, Axis); static void add_element (Grob *me, Grob *); static void set_axes (Grob *, Axis, Axis); static bool has_axis (Grob *, Axis); - static void get_children (Grob *, Link_array *); + static void get_children (Grob *, Link_array__Grob_ *); static bool has_interface (Grob *); }; diff --git a/lily/include/beam.hh b/lily/include/beam.hh index c828ae46f3..c852b44301 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -72,7 +72,7 @@ public: static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *); - static Real score_stem_lengths (Link_array const &stems, + static Real score_stem_lengths (Link_array__Grob_ const &stems, std::vector const &stem_infos, std::vector const &base_stem_ys, std::vector const &stem_xs, diff --git a/lily/include/beaming.hh b/lily/include/beaming.hh index 19ff113571..0e877f684f 100644 --- a/lily/include/beaming.hh +++ b/lily/include/beaming.hh @@ -9,7 +9,7 @@ #ifndef BEAMING_HH #define BEAMING_HH -#include "parray.hh" +#include "std-vector.hh" #include "moment.hh" struct Beaming_info diff --git a/lily/include/book.hh b/lily/include/book.hh index c731e21a50..50943dc0ad 100644 --- a/lily/include/book.hh +++ b/lily/include/book.hh @@ -11,7 +11,7 @@ #include "input.hh" #include "lily-proto.hh" -#include "parray.hh" +#include "std-vector.hh" #include "object-key.hh" #include "std-string.hh" diff --git a/lily/include/break-algorithm.hh b/lily/include/break-algorithm.hh index 9226aa621f..ed1164ffda 100644 --- a/lily/include/break-algorithm.hh +++ b/lily/include/break-algorithm.hh @@ -23,12 +23,12 @@ protected: Paper_score *pscore_; Real linewidth_; - Link_array find_breaks () const; + Link_array__Grob_ find_breaks () const; std::vector find_break_indices () const; void solve_line (Column_x_positions *) const; - bool feasible (Link_array const &) const; + bool feasible (Link_array__Grob_ const &) const; - Simple_spacer_wrapper *generate_spacing_problem (Link_array const &, + Simple_spacer_wrapper *generate_spacing_problem (Link_array__Grob_ const &, Interval) const; virtual std::vector do_solve () const = 0; diff --git a/lily/include/break-align-interface.hh b/lily/include/break-align-interface.hh index 931e219965..289d432cdb 100644 --- a/lily/include/break-align-interface.hh +++ b/lily/include/break-align-interface.hh @@ -14,7 +14,7 @@ class Break_align_interface { public: - static Link_array ordered_elements (Grob *me); + static Link_array__Grob_ ordered_elements (Grob *me); static bool has_interface (Grob *); static void add_element (Grob *me, Grob *add); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM element)); diff --git a/lily/include/column-x-positions.hh b/lily/include/column-x-positions.hh index bc49b37c91..c5d0f928a7 100644 --- a/lily/include/column-x-positions.hh +++ b/lily/include/column-x-positions.hh @@ -7,13 +7,13 @@ #ifndef COLUMN_X_POSITIONS_HH #define COLUMN_X_POSITIONS_HH -#include "parray.hh" +#include "std-vector.hh" #include "lily-proto.hh" struct Column_x_positions { - Link_array cols_; - Link_array loose_cols_; + Link_array__Grob_ cols_; + Link_array__Grob_ loose_cols_; std::vector config_; Real force_; diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh index 3a234bfd78..faddf38f73 100644 --- a/lily/include/context-def.hh +++ b/lily/include/context-def.hh @@ -41,7 +41,7 @@ public: SCM get_translator_names (SCM) const; void set_acceptor (SCM accepts, bool add); - Link_array path_to_acceptable_context (SCM type_string, + Link_array__Context_def_ path_to_acceptable_context (SCM type_string, Output_def *) const; Context *instantiate (SCM extra_ops, Object_key const *); diff --git a/lily/include/context.hh b/lily/include/context.hh index a667f9d408..5c3b93fa14 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -92,7 +92,7 @@ public: std::string id, SCM ops); Context *create_unique_context (SCM context_name, SCM ops); - Link_array path_to_acceptable_context (SCM alias, + Link_array__Context_ path_to_acceptable_context (SCM alias, Output_def *) const; }; diff --git a/lily/include/dimension-cache.hh b/lily/include/dimension-cache.hh index 9b59d1b1fb..fa9147838a 100644 --- a/lily/include/dimension-cache.hh +++ b/lily/include/dimension-cache.hh @@ -10,7 +10,7 @@ #define DIMENSION_CACHE_HH #include "lily-proto.hh" -#include "parray.hh" +#include "std-vector.hh" #include "dimension-cache-callback.hh" #include "lily-guile.hh" diff --git a/lily/include/grob-array.hh b/lily/include/grob-array.hh index 99a0dcd404..7d8bf9be1d 100644 --- a/lily/include/grob-array.hh +++ b/lily/include/grob-array.hh @@ -11,11 +11,11 @@ #include "lily-proto.hh" #include "smobs.hh" -#include "parray.hh" +#include "std-vector.hh" class Grob_array { - Link_array grobs_; + Link_array__Grob_ grobs_; bool ordered_; DECLARE_SIMPLE_SMOBS (Grob_array,); @@ -31,15 +31,15 @@ public: bool empty () const; void clear (); void add (Grob *x) { grobs_.push_back (x); } - void set_array (Link_array const &src); - Link_array &array_reference (); - Link_array const &array () const; + void set_array (Link_array__Grob_ const &src); + Link_array__Grob_ &array_reference (); + Link_array__Grob_ const &array () const; static SCM make_array (); }; DECLARE_UNSMOB (Grob_array, grob_array); -Link_array const &ly_scm2link_array (SCM x); +Link_array__Grob_ const &ly_scm2link_array (SCM x); SCM grob_list_to_grob_array (SCM lst); #endif /* GROB_ARRAY_HH */ diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index c41d0686d0..89b1054552 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -11,7 +11,7 @@ #include "lily-guile.hh" #include "lily-proto.hh" -#include "parray.hh" +#include "std-vector.hh" /* Data container for broadcasts. @@ -29,7 +29,7 @@ public: Context *context () const; Music *music_cause () const; Music *ultimate_music_cause () const; - Link_array origin_contexts (Translator *) const; + Link_array__Context_ origin_contexts (Translator *) const; Grob_info (Translator *, Grob *); Grob_info (); diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 0652c9f815..522cfd555c 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -128,7 +128,7 @@ Item *unsmob_item (SCM); /* refpoints */ Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a); -Grob *common_refpoint_of_array (Link_array const &, Grob *, Axis a); +Grob *common_refpoint_of_array (Link_array__Grob_ const &, Grob *, Axis a); System *get_root_system (Grob *me); /* extents */ diff --git a/lily/include/horizontal-bracket.hh b/lily/include/horizontal-bracket.hh index 4629ecaf9b..79925bc934 100644 --- a/lily/include/horizontal-bracket.hh +++ b/lily/include/horizontal-bracket.hh @@ -17,7 +17,7 @@ struct Horizontal_bracket DECLARE_SCHEME_CALLBACK (print, (SCM)); static Stencil make_bracket (Grob *, Real, Axis, Direction); static Stencil make_enclosing_bracket (Grob *me, Grob *refpoint, - Link_array grobs, + Link_array__Grob_ grobs, Axis a, Direction dir); static bool has_interface (Grob *); }; diff --git a/lily/include/includable-lexer.hh b/lily/include/includable-lexer.hh index 68fed68ebf..f495424f28 100644 --- a/lily/include/includable-lexer.hh +++ b/lily/include/includable-lexer.hh @@ -14,7 +14,7 @@ #endif #include "std-string.hh" -#include "parray.hh" +#include "std-vector.hh" #include "lily-proto.hh" // GIGA urg! @@ -29,7 +29,7 @@ class Includable_lexer : public yyFlexLexer protected: bool close_input (); - Link_array include_stack_; + Link_array__Source_file_ include_stack_; std::vector char_count_stack_; public: diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index 55ee32a171..7c89bdca0e 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -11,7 +11,7 @@ #include "duration.hh" #include "input.hh" -#include "parray.hh" +#include "std-vector.hh" #include "pitch.hh" /** diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 5693b42059..ccbd177226 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -178,4 +178,52 @@ typedef void (*Engraver_void_function_engraver_grob_info) (Engraver *, Grob_info typedef void (*Translator_void_method_ptr) (Translator *); +/* FIXME: when Link_array is dropped, do grand s/r to vector. */ +#if STD_VECTOR + +// FIXME: does not work with sourc-file.cc +// #define Link_array__char_ std::vector + +#define Link_array__char_ Link_array +#define Link_array__Grob_ std::vector +#define Link_array__Accidental_placement_entry_ std::vector +#define Link_array__Audio_item_ std::vector +#define Link_array__Audio_note_ std::vector +#define Link_array__Audio_piano_pedal_ std::vector +#define Link_array__Audio_staff_ std::vector +#define Link_array__Bracket_nesting_node_ std::vector +#define Link_array__Context_ std::vector +#define Link_array__Context_def_ std::vector +#define Link_array__Grob_ std::vector +#define Link_array__Item_ std::vector +#define Link_array__Music_ std::vector +#define Link_array__Note_column_ std::vector +#define Link_array__Output_def_ std::vector +#define Link_array__Slur_configuration_ std::vector +#define Link_array__Source_file_ std::vector +#define Link_array__Spanner_ std::vector +#define Link_array__Tie_configuration_ std::vector +#else /* !STD_VECTOR */ +#define Link_array__char_ Link_array +#define Link_array__Grob_ Link_array +#define Link_array__Accidental_placement_entry_ Link_array +#define Link_array__Audio_item_ Link_array +#define Link_array__Audio_note_ Link_array +#define Link_array__Audio_piano_pedal_ Link_array +#define Link_array__Audio_staff_ Link_array +#define Link_array__Bracket_nesting_node_ Link_array +#define Link_array__Context_ Link_array +#define Link_array__Context_def_ Link_array +#define Link_array__Grob_ Link_array +#define Link_array__Item_ Link_array +#define Link_array__Music_ Link_array +#define Link_array__Note_column_ Link_array +#define Link_array__Output_def_ Link_array +#define Link_array__Slur_configuration_ Link_array +#define Link_array__Source_file_ Link_array +#define Link_array__Spanner_ Link_array +#define Link_array__Tie_configuration_ Link_array +#endif /* !STD_VECTOR */ + + #endif /* LILY_PROTO_HH */ diff --git a/lily/include/midi-walker.hh b/lily/include/midi-walker.hh index 05181eecd6..d98d209242 100644 --- a/lily/include/midi-walker.hh +++ b/lily/include/midi-walker.hh @@ -41,7 +41,7 @@ private: Midi_track *track_; Audio_staff *staff_; int index_; - Link_array *items_; + Link_array__Audio_item_ *items_; PQueue stop_note_queue; Moment last_mom_; }; diff --git a/lily/include/note-collision.hh b/lily/include/note-collision.hh index 1b1bd536f6..70be17119c 100644 --- a/lily/include/note-collision.hh +++ b/lily/include/note-collision.hh @@ -11,7 +11,7 @@ #include "lily-proto.hh" #include "lily-guile.hh" -#include "parray.hh" +#include "std-vector.hh" /** Resolve conflicts between various Note_columns (chords). @@ -26,10 +26,10 @@ class Note_collision_interface { public: - static SCM automatic_shift (Grob *, Drul_array >); + static SCM automatic_shift (Grob *, Drul_array); static SCM forced_shift (Grob *); - static Drul_array > get_clash_groups (Grob *me); + static Drul_array get_clash_groups (Grob *me); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM smob)); static void add_column (Grob *me, Grob *ncol); static bool has_interface (Grob *); diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index 7373e9a0d7..c84fbe1c1c 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -8,7 +8,7 @@ #ifndef PAPER_BOOK_HH #define PAPER_BOOK_HH -#include "parray.hh" +#include "std-vector.hh" #include "protected-scm.hh" #include "smobs.hh" diff --git a/lily/include/paper-column-engraver.hh b/lily/include/paper-column-engraver.hh index 8e8d5f9fa3..ef0fc75363 100644 --- a/lily/include/paper-column-engraver.hh +++ b/lily/include/paper-column-engraver.hh @@ -34,7 +34,7 @@ protected: int breaks_; // used for stat printing Paper_column *command_column_; Paper_column *musical_column_; - Link_array items_; + Link_array__Item_ items_; bool first_; Moment last_moment_; public: diff --git a/lily/include/performance.hh b/lily/include/performance.hh index 4ea823bd11..f264ecdb6c 100644 --- a/lily/include/performance.hh +++ b/lily/include/performance.hh @@ -7,7 +7,7 @@ #ifndef PERFORMANCE_HH #define PERFORMANCE_HH -#include "parray.hh" +#include "std-vector.hh" #include "cons.hh" #include "music-output.hh" @@ -27,7 +27,7 @@ public: void print () const; void write_output (std::string filename); - Link_array audio_staffs_; + Link_array__Audio_staff_ audio_staffs_; Cons *audio_element_list_; Output_def *midi_; }; diff --git a/lily/include/pointer-group-interface.hh b/lily/include/pointer-group-interface.hh index a8e6375229..7ec2d62513 100644 --- a/lily/include/pointer-group-interface.hh +++ b/lily/include/pointer-group-interface.hh @@ -9,7 +9,7 @@ #ifndef POINTER_GROUP_INTERFACE_HH #define POINTER_GROUP_INTERFACE_HH -#include "parray.hh" +#include "std-vector.hh" #include "lily-proto.hh" #include "lily-guile.hh" @@ -21,8 +21,8 @@ public: static void add_grob (Grob *, SCM nm, SCM x); }; -Link_array const &internal_extract_grob_array (Grob const *elt, SCM symbol); -Link_array internal_extract_item_array (Grob const *elt, SCM symbol); +Link_array__Grob_ const &internal_extract_grob_array (Grob const *elt, SCM symbol); +Link_array__Item_ internal_extract_item_array (Grob const *elt, SCM symbol); #define extract_grob_array(x, prop) internal_extract_grob_array (x, ly_symbol2scm (prop)) #define extract_item_array(x, prop) internal_extract_item_array (x, ly_symbol2scm (prop)) @@ -32,9 +32,9 @@ Link_array internal_extract_item_array (Grob const *elt, SCM symbol); representation of grob sets again. */ #define extract_grob_set(grob, prop, set) \ - Link_array const &set (internal_extract_grob_array (grob, ly_symbol2scm (prop))) + Link_array__Grob_ const &set (internal_extract_grob_array (grob, ly_symbol2scm (prop))) #define extract_item_set(grob, prop, set) \ - Link_array set (internal_extract_item_array (grob, ly_symbol2scm (prop))) + Link_array__Item_ set (internal_extract_item_array (grob, ly_symbol2scm (prop))) #endif /* POINTER_GROUP_INTERFACE_HH */ diff --git a/lily/include/score-engraver.hh b/lily/include/score-engraver.hh index 6972f01d2b..286210dde5 100644 --- a/lily/include/score-engraver.hh +++ b/lily/include/score-engraver.hh @@ -17,7 +17,7 @@ class Score_engraver : public virtual Score_translator, { System *system_; - Link_array elems_; + Link_array__Grob_ elems_; Paper_score *pscore_; void typeset_all (); diff --git a/lily/include/score.hh b/lily/include/score.hh index 6cb5cf927d..092ddd0c8d 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -12,7 +12,7 @@ #include "lily-proto.hh" #include "input.hh" -#include "parray.hh" +#include "std-vector.hh" #include "smobs.hh" #include "virtual-methods.hh" #include "std-string.hh" @@ -24,7 +24,7 @@ class Score : public Input SCM music_; public: - Link_array defs_; + Link_array__Output_def_ defs_; std::string user_key_; SCM header_; bool error_found_; diff --git a/lily/include/separating-group-spanner.hh b/lily/include/separating-group-spanner.hh index 4e2f2f4380..b1499339e7 100644 --- a/lily/include/separating-group-spanner.hh +++ b/lily/include/separating-group-spanner.hh @@ -14,7 +14,7 @@ class Separating_group_spanner { static void find_rods (Item *, - Link_array const &separators, + Link_array__Grob_ const &separators, vsize idx, Real); public: diff --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 05d3313094..16c9494ed6 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -9,7 +9,7 @@ #ifndef SIMPLE_SPACER_HH #define SIMPLE_SPACER_HH -#include "parray.hh" +#include "std-vector.hh" #include "lily-proto.hh" #include "smobs.hh" @@ -56,11 +56,11 @@ public: struct Simple_spacer_wrapper { Simple_spacer *spacer_; - Link_array spaced_cols_; - Link_array loose_cols_; + Link_array__Grob_ spaced_cols_; + Link_array__Grob_ loose_cols_; Simple_spacer_wrapper (); - void add_columns (Link_array const &); + void add_columns (Link_array__Grob_ const &); void solve (Column_x_positions *, bool); ~Simple_spacer_wrapper (); private: diff --git a/lily/include/slur-configuration.hh b/lily/include/slur-configuration.hh index 59cc3a5368..285a8da7df 100644 --- a/lily/include/slur-configuration.hh +++ b/lily/include/slur-configuration.hh @@ -10,7 +10,7 @@ #define SLUR_CONFIGURATION_HH #include "bezier.hh" -#include "parray.hh" +#include "std-vector.hh" #include "main.hh" class Slur_configuration diff --git a/lily/include/slur-scoring.hh b/lily/include/slur-scoring.hh index 0bb54bf7c0..51be36672c 100644 --- a/lily/include/slur-scoring.hh +++ b/lily/include/slur-scoring.hh @@ -11,7 +11,7 @@ #include "box.hh" #include "lily-proto.hh" -#include "parray.hh" +#include "std-vector.hh" #include "lily-guile.hh" struct Slur_score_parameters @@ -104,7 +104,7 @@ struct Slur_score_state bool has_same_beam_; Real musical_dy_; - Link_array columns_; + Link_array__Grob_ columns_; std::vector encompass_infos_; std::vector extra_encompass_infos_; @@ -112,7 +112,7 @@ struct Slur_score_state Slur_score_parameters parameters_; Drul_array extremes_; Drul_array base_attachments_; - Link_array configurations_; + Link_array__Slur_configuration_ configurations_; Real staff_space_; Real thickness_; @@ -126,7 +126,7 @@ struct Slur_score_state std::vector generate_avoid_offsets () const; Drul_array get_bound_info () const; void generate_curves () const; - Link_array enumerate_attachments (Drul_array end_ys) const; + Link_array__Slur_configuration_ enumerate_attachments (Drul_array end_ys) const; Drul_array get_base_attachments () const; Drul_array get_y_attachment_range () const; Encompass_info get_encompass_info (Grob *col) const; diff --git a/lily/include/source-file.hh b/lily/include/source-file.hh index 6f7f75e683..42a2be56b2 100644 --- a/lily/include/source-file.hh +++ b/lily/include/source-file.hh @@ -10,12 +10,13 @@ #define SOURCE_FILE_HH #include "std-string.hh" +#include "std-vector.hh" +#include "lily-proto.hh" #include using namespace std; #include "protected-scm.hh" -#include "parray.hh" /** class for reading and mapping a file. @@ -67,7 +68,7 @@ public: std::string name_; private: - Link_array newline_locations_; + Link_array__char_ newline_locations_; istream *istream_; char *contents_str0_; std::vector chs_; diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh index f8161292fe..1b7a86b103 100644 --- a/lily/include/spacing-spanner.hh +++ b/lily/include/spacing-spanner.hh @@ -43,13 +43,13 @@ public: static Real default_bar_spacing (Grob *, Grob *, Grob *, Moment); static Real note_spacing (Grob *, Grob *, Grob *, Spacing_options const *, bool *); static Real get_duration_space (Moment dur, Spacing_options const *, bool *); - static Rational find_shortest (Grob *, Link_array const &); - static Rational effective_shortest_duration (Grob *me, Link_array const &all); + static Rational find_shortest (Grob *, Link_array__Grob_ const &); + static Rational effective_shortest_duration (Grob *me, Link_array__Grob_ const &all); static void breakable_column_spacing (Grob *, Item *l, Item *r, Spacing_options const *); - static void prune_loose_columns (Grob *, Link_array *cols, Spacing_options const *); - static void set_explicit_neighbor_columns (Link_array const &cols); - static void set_implicit_neighbor_columns (Link_array const &cols); - static void generate_springs (Grob *me, Link_array const &cols, Spacing_options const *); + static void prune_loose_columns (Grob *, Link_array__Grob_ *cols, Spacing_options const *); + static void set_explicit_neighbor_columns (Link_array__Grob_ const &cols); + static void set_implicit_neighbor_columns (Link_array__Grob_ const &cols); + static void generate_springs (Grob *me, Link_array__Grob_ const &cols, Spacing_options const *); static void musical_column_spacing (Grob *, Item *, Item *, Spacing_options const *); DECLARE_SCHEME_CALLBACK (set_springs, (SCM)); static bool has_interface (Grob *); diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index 77f272b4ca..594220f2c1 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -36,7 +36,7 @@ class Spanner : public Grob public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); - Link_array broken_intos_; + Link_array__Spanner_ broken_intos_; int get_break_index () const; diff --git a/lily/include/system.hh b/lily/include/system.hh index a13f9c7da3..8b82baeff2 100644 --- a/lily/include/system.hh +++ b/lily/include/system.hh @@ -41,8 +41,8 @@ public: void break_into_pieces (std::vector const &); static bool has_interface (Grob *); - Link_array broken_col_range (Item const *, Item const *) const; - Link_array columns () const; + Link_array__Item_ broken_col_range (Item const *, Item const *) const; + Link_array__Grob_ columns () const; void add_column (Paper_column *); void typeset_grob (Grob *); diff --git a/lily/include/tie-column-format.hh b/lily/include/tie-column-format.hh index a6cb8df5eb..600e11eedd 100644 --- a/lily/include/tie-column-format.hh +++ b/lily/include/tie-column-format.hh @@ -14,7 +14,7 @@ #include "tie-configuration.hh" void set_chord_outline (std::vector *skyline, - Link_array bounds, + Link_array__Item_ bounds, Grob *common, Direction d); void set_tie_config_directions (Ties_configuration *tie_configs_ptr); @@ -26,7 +26,7 @@ void final_shape_adjustment (Tie_configuration &conf, Grob *staff_referencer); void set_chord_outlines (Drul_array< std::vector > *skyline_drul, - Link_array ties, + Link_array__Grob_ ties, Grob *common); void diff --git a/lily/include/tie-formatting-problem.hh b/lily/include/tie-formatting-problem.hh index 2563e206d6..7f89b21a65 100644 --- a/lily/include/tie-formatting-problem.hh +++ b/lily/include/tie-formatting-problem.hh @@ -11,7 +11,7 @@ #define TIE_FORMATTING_PROBLEM_HH #include "drul-array.hh" -#include "parray.hh" +#include "std-vector.hh" #include "skyline.hh" #include "lily-proto.hh" #include "tie-configuration.hh" @@ -110,10 +110,10 @@ public: Ties_configuration generate_optimal_chord_configuration (); Ties_configuration generate_ties_configuration (Ties_configuration const &); Tie_configuration find_optimal_tie_configuration (Tie_specification const &) const; - void from_ties (Link_array const &ties); + void from_ties (Link_array__Grob_ const &ties); void from_tie (Grob *tie); - void from_lv_ties (Link_array const &); - void set_chord_outline (Link_array, Direction); + void from_lv_ties (Link_array__Grob_ const &); + void set_chord_outline (Link_array__Item_, Direction); void set_manual_tie_configuration (SCM); Interval get_attachment (Real) const; Grob *common_x_refpoint () const; diff --git a/lily/include/timing-translator.hh b/lily/include/timing-translator.hh index c535331415..ef13b682cc 100644 --- a/lily/include/timing-translator.hh +++ b/lily/include/timing-translator.hh @@ -12,7 +12,7 @@ #include "moment.hh" #include "translator.hh" -#include "parray.hh" +#include "std-vector.hh" class Timing_translator : public Translator { diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 3abbee33d7..625944ba2d 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -10,7 +10,7 @@ #define TRANSLATOR_GROUP_HH #include "translator.hh" -#include "parray.hh" +#include "std-vector.hh" typedef void (Translator:: *Translator_method) (void); typedef void (Translator_group:: *Translator_group_method) (void); diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index b93de11d6a..3b0c0d735d 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -25,7 +25,7 @@ public: static void get_bounds (Grob *, Grob **, Grob **); static void add_column (Grob *me, Item *); static void add_beam (Grob *me, Grob *); - static Grob *parallel_beam (Grob *me, Link_array const &cols, bool *equally_long); + static Grob *parallel_beam (Grob *me, Link_array__Grob_ const &cols, bool *equally_long); static void calc_position_and_height (Grob *, Real *, Real *dy); static Stencil make_bracket (Grob *me, Axis protusion_axis, Offset dz, Drul_array height, diff --git a/lily/keyword.cc b/lily/keyword.cc index 7279ba5291..84065ab4f6 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -30,6 +30,5 @@ Keyword_table::lookup (char const *s) const vsize idx = binary_search (table_, e, tabcmp); if (idx != VPOS) return table_[idx].tokcode_; - else - return VPOS; + return VPOS; } diff --git a/lily/laissez-vibrer-engraver.cc b/lily/laissez-vibrer-engraver.cc index d361298c56..33cf854eb4 100644 --- a/lily/laissez-vibrer-engraver.cc +++ b/lily/laissez-vibrer-engraver.cc @@ -19,7 +19,7 @@ class Laissez_vibrer_engraver : public Engraver Music *event_; Grob *lv_column_; - Link_array lv_ties_; + Link_array__Grob_ lv_ties_; void stop_translation_timestep (); DECLARE_ACKNOWLEDGER (note_head); diff --git a/lily/laissez-vibrer-tie-column.cc b/lily/laissez-vibrer-tie-column.cc index 449181e61d..3553d35b70 100644 --- a/lily/laissez-vibrer-tie-column.cc +++ b/lily/laissez-vibrer-tie-column.cc @@ -42,9 +42,9 @@ Laissez_vibrer_tie_column::calc_positioning_done (SCM smob) Grob *me = unsmob_grob (smob); extract_grob_set (me, "ties", lv_ro_ties); - Link_array lv_ties (lv_ro_ties); + Link_array__Grob_ lv_ties (lv_ro_ties); - lv_ties.sort (&Laissez_vibrer_tie::compare); + vector_sort (lv_ties, &Laissez_vibrer_tie::compare); Ties_configuration ties_config; diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index 6d2ff577ec..35a17bc3e7 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -21,7 +21,7 @@ protected: void process_music (); private: - Link_array events_; + Link_array__Music_ events_; Audio_text *audio_; }; diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index c429b67b48..574ace67cb 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -29,7 +29,7 @@ protected: private: Music *rest_ev_; - Link_array text_events_; + Link_array__Music_ text_events_; int start_measure_; Rational last_main_moment_; Moment stop_moment_; @@ -39,8 +39,8 @@ private: Spanner *last_rest_; Spanner *mmrest_; - Link_array numbers_; - Link_array last_numbers_; + Link_array__Spanner_ numbers_; + Link_array__Spanner_ last_numbers_; }; Multi_measure_rest_engraver::Multi_measure_rest_engraver () diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 1e74bbba34..496e19f93d 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -47,7 +47,7 @@ class New_fingering_engraver : public Engraver std::vector articulations_; std::vector string_numbers_; - Link_array heads_; + Link_array__Grob_ heads_; Grob *stem_; public: diff --git a/lily/note-collision.cc b/lily/note-collision.cc index e7a6c621c8..db794d5092 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -25,7 +25,7 @@ void check_meshing_chords (Grob *me, Drul_array > *offsets, Drul_array > const &extents, - Drul_array > const &clash_groups) + Drul_array const &clash_groups) { if (!extents[UP].size () || ! extents[DOWN].size ()) @@ -280,7 +280,7 @@ SCM Note_collision_interface::calc_positioning_done (SCM smob) { Grob *me = unsmob_grob (smob); - Drul_array > cg = get_clash_groups (me); + Drul_array cg = get_clash_groups (me); Direction d = UP; do @@ -309,7 +309,7 @@ Note_collision_interface::calc_positioning_done (SCM smob) } while (flip (&d) != UP); - Link_array done; + Link_array__Grob_ done; Real left_most = 1e6; std::vector amounts; @@ -328,7 +328,8 @@ Note_collision_interface::calc_positioning_done (SCM smob) Grob *s = unsmob_grob (scm_caar (autos)); Real amount = scm_to_double (scm_cdar (autos)) * wid; - if (!done.find (s)) + vsize x = find (done, s) - done.begin (); + if (x == VPOS || x >= done.size ()) { done.push_back (s); amounts.push_back (amount); @@ -343,10 +344,10 @@ Note_collision_interface::calc_positioning_done (SCM smob) return SCM_BOOL_T; } -Drul_array < Link_array > +Drul_array < Link_array__Grob_ > Note_collision_interface::get_clash_groups (Grob *me) { - Drul_array > clash_groups; + Drul_array clash_groups; extract_grob_set (me, "elements", elements); for (vsize i = 0; i < elements.size (); i++) @@ -359,8 +360,8 @@ Note_collision_interface::get_clash_groups (Grob *me) Direction d = UP; do { - Link_array &clashes (clash_groups[d]); - clashes.sort (Note_column::shift_compare); + Link_array__Grob_ &clashes (clash_groups[d]); + vector_sort (clashes, Note_column::shift_compare); } while ((flip (&d)) != UP); @@ -374,7 +375,7 @@ Note_collision_interface::get_clash_groups (Grob *me) */ SCM Note_collision_interface::automatic_shift (Grob *me, - Drul_array < Link_array + Drul_array < Link_array__Grob_ > clash_groups) { Drul_array < std::vector > shifts; @@ -384,7 +385,7 @@ Note_collision_interface::automatic_shift (Grob *me, do { std::vector &shift (shifts[d]); - Link_array &clashes (clash_groups[d]); + Link_array__Grob_ &clashes (clash_groups[d]); for (vsize i = 0; i < clashes.size (); i++) { diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 3a8705168c..109e4905c7 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -20,9 +20,9 @@ using namespace std; class Note_heads_engraver : public Engraver { - Link_array notes_; - Link_array dots_; - Link_array note_evs_; + Link_array__Item_ notes_; + Link_array__Item_ dots_; + Link_array__Music_ note_evs_; public: TRANSLATOR_DECLARATIONS (Note_heads_engraver); diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index 1fc63b0242..c0ee4986f6 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -14,8 +14,8 @@ class Note_name_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (Note_name_engraver); - Link_array events_; - Link_array texts_; + Link_array__Music_ events_; + Link_array__Item_ texts_; virtual bool try_music (Music *m); void process_music (); void stop_translation_timestep (); diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 77c0a21bf8..cfb8edaf51 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -28,8 +28,8 @@ protected: void process_music (); private: - Link_array note_evs_; - Link_array notes_; + Link_array__Music_ note_evs_; + Link_array__Audio_note_ notes_; }; void @@ -45,7 +45,8 @@ Note_performer::process_music () while (note_evs_.size ()) { - Music *n = note_evs_.pop (); + Music *n = note_evs_.back (); + note_evs_.pop_back (); SCM pit = n->get_property ("pitch"); if (Pitch *pitp = unsmob_pitch (pit)) diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 78b1bcaf4a..0ddf4bc540 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -39,7 +39,7 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, Interval left_head_wid; do { - Link_array const &items (ly_scm2link_array (props [d])); + Link_array__Grob_ const &items (ly_scm2link_array (props [d])); for (vsize i = items.size (); i--;) { Item *it = dynamic_cast (items[i]); @@ -223,7 +223,7 @@ Note_spacing::right_column (Grob *me) if (prune && a) { - Link_array &right = a->array_reference (); + Link_array__Grob_ &right = a->array_reference (); for (vsize i = right.size (); i--;) { if (dynamic_cast (right[i])->get_column () != mincol) @@ -269,7 +269,7 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, do { - Link_array const &items (ly_scm2link_array (props [d])); + Link_array__Grob_ const &items (ly_scm2link_array (props [d])); for (vsize i = 0; i < items.size (); i++) { Item *it = dynamic_cast (items[i]); diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index d3eeccedfc..c0750c06c8 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -18,7 +18,7 @@ class Output_property_engraver : public Engraver { TRANSLATOR_DECLARATIONS (Output_property_engraver); protected: - Link_array props_; + Link_array__Music_ props_; DECLARE_ACKNOWLEDGER (grob) void stop_translation_timestep (); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 5688d49e61..f7a1ae5e8b 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -157,7 +157,7 @@ Paper_column::before_line_breaking (SCM grob) if (!ga) return SCM_UNSPECIFIED; - Link_array &array (ga->array_reference ()); + Link_array__Grob_ &array (ga->array_reference ()); for (vsize i = array.size (); i--;) { diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 6bc05c4e13..c983fe0289 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -86,7 +86,7 @@ Paper_score::process () down the road. doubly, also done in Score_engraver */ - Link_array pc (system_->columns ()); + Link_array__Grob_ pc (system_->columns ()); pc[0]->set_property ("breakable", SCM_BOOL_T); pc.back ()->set_property ("breakable", SCM_BOOL_T); diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index b8eed4092d..64f76ae3a0 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -27,8 +27,8 @@ class Phrasing_slur_engraver : public Engraver { Drul_array events_; Music *running_slur_start_; - Link_array slurs_; - Link_array end_slurs_; + Link_array__Grob_ slurs_; + Link_array__Grob_ end_slurs_; protected: virtual bool try_music (Music *); diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 1177347f09..e15f8deb3d 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -79,7 +79,7 @@ private: occurs simultaneously then extra space can be added between them. */ - Link_array previous_; + Link_array__Spanner_ previous_; void del_linespanner (Spanner *); void create_text_grobs (Pedal_info *p, bool); @@ -438,8 +438,8 @@ Piano_pedal_engraver::finalize () void Piano_pedal_engraver::del_linespanner (Spanner *g) { - int idx = previous_.find_index (g); - if (idx >= 0) + vsize idx = find (previous_, g) - previous_.begin (); + if (idx != VPOS && idx < previous_.size ()) previous_.erase (previous_.begin () + idx); } diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index f4ac60018a..4cf4415f03 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -36,7 +36,7 @@ protected: void start_translation_timestep (); private: - Link_array audios_; + Link_array__Audio_piano_pedal_ audios_; Pedal_info *info_alist_; }; diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index ec983e5d0c..0cc9155e05 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -35,7 +35,7 @@ private: Item *trill_group_; Item *trill_accidental_; - Link_array heads_; + Link_array__Grob_ heads_; void make_trill (Music *); }; diff --git a/lily/pointer-group-interface.cc b/lily/pointer-group-interface.cc index 967c4ccec6..51354ffb50 100644 --- a/lily/pointer-group-interface.cc +++ b/lily/pointer-group-interface.cc @@ -40,26 +40,26 @@ Pointer_group_interface::add_grob (Grob *me, SCM sym, Grob *p) arr->add (p); } -static Link_array empty_array; +static Link_array__Grob_ empty_array; -Link_array const & +Link_array__Grob_ const & ly_scm2link_array (SCM x) { Grob_array *arr = unsmob_grob_array (x); return arr ? arr->array () : empty_array; } -Link_array const & +Link_array__Grob_ const & internal_extract_grob_array (Grob const *elt, SCM symbol) { return ly_scm2link_array (elt->internal_get_object (symbol)); } -Link_array +Link_array__Item_ internal_extract_item_array (Grob const *elt, SCM symbol) { Grob_array *arr = unsmob_grob_array (elt->internal_get_object (symbol)); - Link_array items; + Link_array__Item_ items; for (vsize i = 0; arr && i < arr->size (); i++) items.push_back (arr->item (i)); diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index 2d2b6df053..1ee16363ae 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -15,7 +15,7 @@ class Rest_collision_engraver : public Engraver { Item *rest_collision_; int rest_count_; - Link_array note_columns_; + Link_array__Grob_ note_columns_; protected: DECLARE_ACKNOWLEDGER (note_column); void process_acknowledged (); diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 1921aa5a17..aebdf84cf8 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -92,8 +92,8 @@ Rest_collision::calc_positioning_done (SCM smob) Grob *me = unsmob_grob (smob); extract_grob_set (me, "elements", elts); - Link_array rests; - Link_array notes; + Link_array__Grob_ rests; + Link_array__Grob_ notes; for (vsize i = 0; i < elts.size (); i++) { @@ -137,7 +137,7 @@ Rest_collision::calc_positioning_done (SCM smob) This is incomplete: in case of an uneven number of rests, the center one should be centered on the staff. */ - Drul_array > ordered_rests; + Drul_array ordered_rests; for (vsize i = 0; i < rests.size (); i++) { Grob *r = Note_column::get_rest (rests[i]); @@ -151,7 +151,7 @@ Rest_collision::calc_positioning_done (SCM smob) Direction d = LEFT; do - ordered_rests[d].sort (Note_column::shift_compare); + vector_sort (ordered_rests[d], Note_column::shift_compare); while (flip (&d) != LEFT) ; diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index ebc156fc95..2ca4cdca7c 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -41,7 +41,7 @@ class Rhythmic_column_engraver : public Engraver { - Link_array rheads_; + Link_array__Grob_ rheads_; Grob *stem_; Grob *note_column_; Grob *dotcol_; diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index 41555cdbff..ccbe0f6112 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -18,7 +18,7 @@ class Script_column_engraver : public Engraver { Grob *scol_; - Link_array scripts_; + Link_array__Item_ scripts_; public: TRANSLATOR_DECLARATIONS (Script_column_engraver); diff --git a/lily/script-column.cc b/lily/script-column.cc index bfd95f999b..0cc14ba48f 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -42,7 +42,7 @@ Script_column::before_line_breaking (SCM smob) { Grob *me = unsmob_grob (smob); Drul_array scripts_drul (SCM_EOL, SCM_EOL); - Link_array staff_sided; + Link_array__Grob_ staff_sided; extract_grob_set (me, "scripts", scripts); for (vsize i = 0; i < scripts.size (); i++) diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index 94aac09734..a5b076bc86 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -16,7 +16,7 @@ void Separating_group_spanner::find_rods (Item *r, - Link_array const &separators, + Link_array__Grob_ const &separators, vsize idx, Real padding) { diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 1db11947a3..b50acd3143 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -24,7 +24,7 @@ struct Spacings { Item *staff_spacing_; - Link_array note_spacings_; + Link_array__Item_ note_spacings_; Spacings () { diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index be700c693c..900fd77988 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -376,9 +376,9 @@ compare_paper_column_rank (Grob *const &a, } void -Simple_spacer_wrapper::add_columns (Link_array const &icols) +Simple_spacer_wrapper::add_columns (Link_array__Grob_ const &icols) { - Link_array cols (icols); + Link_array__Grob_ cols (icols); cols.clear (); for (vsize i = 0; i < icols.size (); i++) @@ -418,8 +418,8 @@ Simple_spacer_wrapper::add_columns (Link_array const &icols) scm_is_pair (s); s = scm_cdr (s)) { Grob *other = unsmob_grob (scm_caar (s)); - int j = binsearch_links (cols, other, &compare_paper_column_rank); - if (j >= 0 && cols[j] == other) + vsize j = binary_search (cols, other, &compare_paper_column_rank); + if (j != VPOS && cols[j] == other) spacer_->add_rod (i, j, scm_to_double (scm_cdar (s))); } diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 9fee28767a..a0deb271dc 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -26,8 +26,8 @@ class Slur_engraver : public Engraver { Drul_array events_; Music *running_slur_start_; - Link_array slurs_; - Link_array end_slurs_; + Link_array__Grob_ slurs_; + Link_array__Grob_ end_slurs_; void set_melisma (bool); diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 19ce9ee47c..71a6470b0c 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -635,7 +635,7 @@ std::vector Slur_score_state::generate_avoid_offsets () const { std::vector avoid; - Link_array encompasses = columns_; + Link_array__Grob_ encompasses = columns_; for (vsize i = 0; i < encompasses.size (); i++) { @@ -689,10 +689,10 @@ Slur_score_state::generate_curves () const configurations_[i]->generate_curve (*this, r_0, h_inf, avoid); } -Link_array +Link_array__Slur_configuration_ Slur_score_state::enumerate_attachments (Drul_array end_ys) const { - Link_array scores; + Link_array__Slur_configuration_ scores; Drul_array os; os[LEFT] = base_attachments_[LEFT]; diff --git a/lily/source-file.cc b/lily/source-file.cc index a25d071074..041308dbc8 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -324,7 +324,7 @@ Source_file::get_line (char const *pos_str0) const binary_search_bounds (newline_locations_, pos_str0, - Link_array::default_compare, + default_compare, &lo, &hi); if (*pos_str0 == '\n') diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index bcac1ea5f7..e878d264a1 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -126,10 +126,10 @@ is_loose_column (Grob *l, Grob *c, Grob *r, Spacing_options const *options) between. */ void -Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, +Spacing_spanner::prune_loose_columns (Grob *me, Link_array__Grob_ *cols, Spacing_options const *options) { - Link_array newcols; + Link_array__Grob_ newcols; for (vsize i = 0; i < cols->size (); i++) { @@ -228,7 +228,7 @@ Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, Set neighboring columns determined by the spacing-wishes grob property. */ void -Spacing_spanner::set_explicit_neighbor_columns (Link_array const &cols) +Spacing_spanner::set_explicit_neighbor_columns (Link_array__Grob_ const &cols) { for (vsize i = 0; i < cols.size (); i++) { @@ -300,7 +300,7 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array const &cols) yet. Only do breakable non-musical columns, and musical columns. */ void -Spacing_spanner::set_implicit_neighbor_columns (Link_array const &cols) +Spacing_spanner::set_implicit_neighbor_columns (Link_array__Grob_ const &cols) { for (vsize i = 0; i < cols.size (); i++) { diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index 9caba57552..bc0594bed0 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -38,7 +38,7 @@ set_loose_columns (System *which, Column_x_positions const *posns) Item *left = 0; Item *right = 0; - Link_array clique; + Link_array__Item_ clique; while (1) { SCM between = loose->get_object ("between-cols"); diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 6300c99794..39638ff007 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -35,7 +35,7 @@ using namespace std; */ Rational Spacing_spanner::effective_shortest_duration (Grob *me, - Link_array const &all) + Link_array__Grob_ const &all) { SCM preset_shortest = me->get_property ("common-shortest-duration"); Rational global_shortest; @@ -61,7 +61,7 @@ Spacing_spanner::set_springs (SCM smob) /* can't use get_system() ? --hwn. */ - Link_array all (get_root_system (me)->columns ()); + Link_array__Grob_ all (get_root_system (me)->columns ()); set_explicit_neighbor_columns (all); @@ -86,7 +86,7 @@ Spacing_spanner::set_springs (SCM smob) stuff, then. */ Rational -Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) +Spacing_spanner::find_shortest (Grob *me, Link_array__Grob_ const &cols) { /* ascending in duration @@ -225,7 +225,7 @@ Spacing_spanner::generate_pair_spacing (Grob *me, void Spacing_spanner::generate_springs (Grob *me, - Link_array const &cols, + Link_array__Grob_ const &cols, Spacing_options const *options) { Paper_column *next = 0; diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index 998d2693a2..1e992e16a3 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -30,7 +30,7 @@ protected: private: Item *span_arpeggio_; - Link_array arpeggios_; + Link_array__Grob_ arpeggios_; }; Span_arpeggio_engraver::Span_arpeggio_engraver () diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 158663a979..8ddd16c08d 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -22,7 +22,7 @@ dependencies to the spanbars. class Span_bar_engraver : public Engraver { Item *spanbar_; - Link_array bars_; + Link_array__Item_ bars_; public: TRANSLATOR_DECLARATIONS (Span_bar_engraver); diff --git a/lily/spanner.cc b/lily/spanner.cc index e80f1efce3..1a8ae94ed9 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -81,7 +81,7 @@ Spanner::do_break_processing () else { System *root = get_root_system (this); - Link_array break_points = root->broken_col_range (left, right); + Link_array__Item_ break_points = root->broken_col_range (left, right); break_points.insert (break_points.begin () + 0, left); break_points.push_back (right); @@ -124,7 +124,7 @@ Spanner::do_break_processing () } } } - broken_intos_.sort (Spanner::compare); + vector_sort (broken_intos_, Spanner::compare); for (vsize i = broken_intos_.size ();i--;) broken_intos_[i]->break_index_ = i; } @@ -238,12 +238,10 @@ Spanner::get_system () const Grob * Spanner::find_broken_piece (System *l) const { - int idx = binsearch_links (broken_intos_, (Spanner *)l, Spanner::compare); - - if (idx < 0) - return 0; - else + vsize idx = binary_search (broken_intos_, (Spanner *)l, Spanner::compare); + if (idx != VPOS) return broken_intos_ [idx]; + return 0; } int @@ -337,7 +335,7 @@ int broken_spanner_index (Spanner *sp) { Spanner *parent = dynamic_cast (sp->original ()); - return parent->broken_intos_.find_index (sp); + return find (parent->broken_intos_, sp) - parent->broken_intos_.begin (); } Spanner * diff --git a/lily/stanza-number-align-engraver.cc b/lily/stanza-number-align-engraver.cc index 0a40dcac36..3f80169b0c 100644 --- a/lily/stanza-number-align-engraver.cc +++ b/lily/stanza-number-align-engraver.cc @@ -21,8 +21,8 @@ public: TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver); protected: - Link_array lyrics_; - Link_array stanza_numbers_; + Link_array__Grob_ lyrics_; + Link_array__Grob_ stanza_numbers_; DECLARE_ACKNOWLEDGER (lyric_syllable); DECLARE_ACKNOWLEDGER (stanza_number); diff --git a/lily/stem.cc b/lily/stem.cc index 937b17c824..111eda0532 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -367,12 +367,12 @@ Stem::calc_positioning_done (SCM smob) return SCM_BOOL_T; extract_grob_set (me, "note-heads", ro_heads); - Link_array heads (ro_heads); - heads.sort (compare_position); + Link_array__Grob_ heads (ro_heads); + vector_sort (heads, compare_position); Direction dir = get_grob_direction (me); if (dir < 0) - heads.reverse (); + reverse (heads); Real thick = thickness (me); diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index 6bcdea73b0..9808148fd9 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -32,7 +32,7 @@ public: struct Bracket_nesting_group : public Bracket_nesting_node { Spanner *delimiter_; - Link_array children_; + Link_array__Bracket_nesting_node_ children_; SCM symbol_; void from_list (SCM ); diff --git a/lily/system.cc b/lily/system.cc index 423fbac24f..6bcae7ffba 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -106,7 +106,7 @@ System::derived_mark () const } static void -fixup_refpoints (Link_array const &grobs) +fixup_refpoints (Link_array__Grob_ const &grobs) { for (vsize i = grobs.size (); i--;) grobs[i]->fixup_refpoint (); @@ -207,7 +207,7 @@ System::break_into_pieces (std::vector const &breaking) System *system = dynamic_cast (clone (i)); system->rank_ = i; - Link_array c (breaking[i].cols_); + Link_array__Grob_ c (breaking[i].cols_); pscore_->typeset_system (system); system->set_bound (LEFT, c[0]); @@ -317,9 +317,9 @@ System::post_processing () This might seem inefficient, but Stencils are cached per grob anyway. */ - Link_array all_elts_sorted (all_elements_->array ()); - all_elts_sorted.default_sort (); - all_elts_sorted.uniq (); + Link_array__Grob_ all_elts_sorted (all_elements_->array ()); + vector_sort (all_elts_sorted, default_compare); + uniq (all_elts_sorted); this->get_stencil (); for (vsize i = all_elts_sorted.size (); i--;) { @@ -399,10 +399,10 @@ System::get_paper_system () return pl->unprotect (); } -Link_array +Link_array__Item_ System::broken_col_range (Item const *left, Item const *right) const { - Link_array ret; + Link_array__Item_ ret; left = left->get_column (); right = right->get_column (); @@ -430,7 +430,7 @@ System::broken_col_range (Item const *left, Item const *right) const /** Return all columns, but filter out any unused columns , since they might disrupt the spacing problem. */ -Link_array +Link_array__Grob_ System::columns () const { extract_grob_set (this, "columns", ro_columns); @@ -443,7 +443,7 @@ System::columns () const break; } - Link_array columns; + Link_array__Grob_ columns; for (int i = 0; i <= last_breakable; i++) { if (Paper_column::is_used (ro_columns[i])) diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index 6da82d3fdd..7f777c8374 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -26,11 +26,11 @@ using namespace std; */ class Tab_note_heads_engraver : public Engraver { - Link_array notes_; + Link_array__Item_ notes_; - Link_array dots_; - Link_array note_events_; - Link_array tabstring_events_; + Link_array__Item_ dots_; + Link_array__Music_ note_events_; + Link_array__Music_ tabstring_events_; public: TRANSLATOR_DECLARATIONS (Tab_note_heads_engraver); diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index d2eb4055f4..7ada54bb7c 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -18,8 +18,8 @@ */ class Text_engraver : public Engraver { - Link_array evs_; - Link_array texts_; + Link_array__Music_ evs_; + Link_array__Item_ texts_; public: TRANSLATOR_DECLARATIONS (Text_engraver); protected: diff --git a/lily/tie-column-format.cc b/lily/tie-column-format.cc index 68afe8f303..7c6bcbb11b 100644 --- a/lily/tie-column-format.cc +++ b/lily/tie-column-format.cc @@ -10,7 +10,7 @@ #include "stem.hh" #include "note-head.hh" #include "tie.hh" -#include "parray.hh" +#include "std-vector.hh" #include "spanner.hh" #include "item.hh" #include "staff-symbol-referencer.hh" diff --git a/lily/tie-column.cc b/lily/tie-column.cc index a6633aca6e..6962ccf369 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -70,7 +70,7 @@ Tie_column::calc_positioning_done (SCM smob) { Grob *me = unsmob_grob (smob); extract_grob_set (me, "ties", ro_ties); - Link_array ties (ro_ties); + Link_array__Grob_ ties (ro_ties); if (!ties.size ()) return SCM_BOOL_T; @@ -82,7 +82,7 @@ Tie_column::calc_positioning_done (SCM smob) return SCM_BOOL_T; } - ties.sort (&Tie::compare); + vector_sort (ties, &Tie::compare); Tie_formatting_problem problem; problem.from_ties (ties); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 9ec95d91a1..c78b99286c 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -48,9 +48,9 @@ struct Head_event_tuple class Tie_engraver : public Engraver { Music *event_; - Link_array now_heads_; + Link_array__Grob_ now_heads_; std::vector heads_to_tie_; - Link_array ties_; + Link_array__Grob_ ties_; Spanner *tie_column_; diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index d1462d4f4b..8309db2660 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -59,7 +59,7 @@ Tie_formatting_problem::~Tie_formatting_problem () } void -Tie_formatting_problem::set_chord_outline (Link_array bounds, +Tie_formatting_problem::set_chord_outline (Link_array__Item_ bounds, Direction d) { Real staff_space = Staff_symbol_referencer::staff_space (bounds[0]); @@ -163,7 +163,7 @@ Tie_formatting_problem::set_chord_outline (Link_array bounds, void Tie_formatting_problem::from_tie (Grob *tie) { - Link_array ties; + Link_array__Grob_ ties; ties.push_back (tie); from_ties (ties); @@ -177,7 +177,7 @@ Tie_formatting_problem::common_x_refpoint () const } void -Tie_formatting_problem::from_ties (Link_array const &ties) +Tie_formatting_problem::from_ties (Link_array__Grob_ const &ties) { if (ties.empty ()) return; @@ -194,7 +194,7 @@ Tie_formatting_problem::from_ties (Link_array const &ties) Direction d = LEFT; do { - Link_array bounds; + Link_array__Item_ bounds; for (vsize i = 0; i < ties.size (); i++) { @@ -231,13 +231,13 @@ Tie_formatting_problem::from_ties (Link_array const &ties) } void -Tie_formatting_problem::from_lv_ties (Link_array const &lv_ties) +Tie_formatting_problem::from_lv_ties (Link_array__Grob_ const &lv_ties) { if (lv_ties.empty ()) return; details_.from_grob (lv_ties[0]); - Link_array heads; + Link_array__Item_ heads; for (vsize i = 0; i < lv_ties.size (); i++) { @@ -477,7 +477,7 @@ Tie_formatting_problem::score_configuration (Tie_configuration const &conf) cons Tie_configuration Tie_formatting_problem::find_optimal_tie_configuration (Tie_specification const &spec) const { - Link_array confs; + Link_array__Tie_configuration_ confs; int pos = spec.position_; Direction dir = spec.manual_dir_; diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 146499dbaa..2ca32323d8 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -72,7 +72,7 @@ flatten_number_pair_property (Grob *me, Grob * -Tuplet_bracket::parallel_beam (Grob *me_grob, Link_array const &cols, bool *equally_long) +Tuplet_bracket::parallel_beam (Grob *me_grob, Link_array__Grob_ const &cols, bool *equally_long) { Spanner *me = dynamic_cast (me_grob); diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index ef54824044..2845d4c445 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -41,7 +41,7 @@ public: protected: std::vector tuplets_; - Link_array last_tuplets_; + Link_array__Spanner_ last_tuplets_; DECLARE_ACKNOWLEDGER (note_column); virtual bool try_music (Music *r); virtual void finalize (); diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index de78c3f835..2b2930e9b1 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -117,9 +117,10 @@ Vertical_align_engraver::acknowledge_axis_group (Grob_info i) if (before_grob || after_grob) { Grob_array *ga = unsmob_grob_array (valign_->get_object ("elements")); - Link_array &arr = ga->array_reference (); + Link_array__Grob_ &arr = ga->array_reference (); - Grob *added = arr.pop (); + Grob *added = arr.back (); + arr.pop_back (); for (vsize i = 0; i < arr.size (); i++) { if (arr[i] == before_grob) -- 2.39.2