From 64313890b232c731d432e5b096f30bffc3f3756d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 31 Jan 2006 00:30:44 +0000 Subject: [PATCH] * configure.in (--enable-std-vector): New option. (--enable-std-string): On by default. * flower/include/std-vector.hh: New file. Enable switch to std::vector, update client code. --- ChangeLog | 8 + configure.in | 14 +- flower/file-path.cc | 8 +- flower/include/array.hh | 162 +++++++---- flower/include/array.icc | 59 ++-- flower/include/file-name.hh | 2 +- flower/include/file-path.hh | 7 +- flower/include/flower-proto.hh | 14 +- flower/include/guile-compatibility.hh | 9 +- flower/include/interval-set.hh | 4 +- flower/include/parray.hh | 63 +++-- flower/include/polynomial.hh | 16 +- flower/include/pqueue.hh | 42 ++- flower/include/std-string.hh | 3 +- flower/include/std-vector.hh | 293 ++++++++++++++++++++ flower/include/string-convert.hh | 3 +- flower/interval-set.cc | 4 +- flower/polynomial.cc | 74 ++--- flower/std-string.cc | 6 + flower/string-convert.cc | 18 +- lily/accidental-engraver.cc | 24 +- lily/accidental-placement.cc | 69 +++-- lily/accidental.cc | 18 +- lily/align-interface.cc | 41 ++- lily/arpeggio.cc | 8 +- lily/audio-column.cc | 2 +- lily/audio-element-info.cc | 2 +- lily/audio-staff.cc | 2 +- lily/auto-beam-engraver.cc | 6 +- lily/auto-change-iterator.cc | 2 +- lily/axis-group-engraver.cc | 4 +- lily/axis-group-interface-scheme.cc | 2 +- lily/axis-group-interface.cc | 6 +- lily/beam-concave.cc | 34 +-- lily/beam-quanting.cc | 58 ++-- lily/beam.cc | 76 ++--- lily/beaming-info.cc | 6 +- lily/bezier.cc | 34 +-- lily/box.cc | 2 +- lily/break-algorithm.cc | 16 +- lily/break-align-interface.cc | 34 +-- lily/break-substitution.cc | 30 +- lily/chord-name-engraver.cc | 4 +- lily/cluster-engraver.cc | 4 +- lily/cluster.cc | 28 +- lily/coherent-ligature-engraver.cc | 12 +- lily/collision-engraver.cc | 4 +- lily/completion-note-heads-engraver.cc | 19 +- lily/context-def.cc | 10 +- lily/context.cc | 4 +- lily/custos-engraver.cc | 10 +- lily/dot-column.cc | 8 +- lily/drum-note-engraver.cc | 14 +- lily/drum-note-performer.cc | 6 +- lily/enclosing-bracket.cc | 2 +- lily/engraver-group.cc | 4 +- lily/extender-engraver.cc | 2 +- lily/figured-bass-continuation.cc | 2 +- lily/figured-bass-engraver.cc | 91 +++--- lily/fingering-engraver.cc | 10 +- lily/font-config.cc | 8 +- lily/general-scheme.cc | 2 +- lily/global-context.cc | 2 +- lily/global-ctor.cc | 10 +- lily/gourlay-breaking.cc | 43 +-- lily/gregorian-ligature-engraver.cc | 10 +- lily/grid-line-interface.cc | 2 +- lily/grid-line-span-engraver.cc | 6 +- lily/grob-array-scheme.cc | 8 +- lily/grob-array.cc | 12 +- lily/grob-info.cc | 2 +- lily/grob-pq-engraver.cc | 6 +- lily/grob-scheme.cc | 2 +- lily/grob.cc | 2 +- lily/hairpin.cc | 2 +- lily/hara-kiri-group-spanner.cc | 2 +- lily/horizontal-bracket-engraver.cc | 8 +- lily/hyphen-engraver.cc | 2 +- lily/includable-lexer.cc | 35 +-- lily/include/accidental-interface.hh | 2 +- lily/include/beam.hh | 6 +- lily/include/beaming.hh | 2 +- lily/include/bezier.hh | 12 +- lily/include/break-algorithm.hh | 6 +- lily/include/coherent-ligature-engraver.hh | 6 +- lily/include/column-x-positions.hh | 2 +- lily/include/engraver-group.hh | 2 +- lily/include/gourlay-breaking.hh | 2 +- lily/include/gregorian-ligature-engraver.hh | 4 +- lily/include/grob-array.hh | 12 +- lily/include/includable-lexer.hh | 6 +- lily/include/keyword.hh | 6 +- lily/include/least-squares.hh | 4 +- lily/include/ligature-engraver.hh | 6 +- lily/include/lily-parser.hh | 4 +- lily/include/lookup.hh | 2 +- lily/include/main.hh | 10 +- lily/include/misc.hh | 4 +- lily/include/music-iterator.hh | 2 +- lily/include/paper-outputter.hh | 2 +- lily/include/paper-score.hh | 2 +- lily/include/performer-group.hh | 2 +- lily/include/pitch.hh | 2 +- lily/include/simple-spacer.hh | 2 +- lily/include/skyline.hh | 20 +- lily/include/slur-configuration.hh | 2 +- lily/include/slur-scoring.hh | 8 +- lily/include/stem.hh | 2 +- lily/include/system.hh | 2 +- lily/include/tfm-reader.hh | 8 +- lily/include/tfm.hh | 10 +- lily/include/tie-column-format.hh | 4 +- lily/include/tie-configuration.hh | 4 +- lily/include/tie-formatting-problem.hh | 6 +- lily/include/translator-dispatch-list.hh | 4 +- lily/include/translator-group.hh | 2 +- lily/include/translator.hh | 2 +- lily/include/translator.icc | 8 +- lily/keyword.cc | 10 +- lily/laissez-vibrer-engraver.cc | 2 +- lily/laissez-vibrer-tie-column.cc | 2 +- lily/least-squares.cc | 4 +- lily/ledger-line-spanner.cc | 10 +- lily/lexer.ll | 2 +- lily/ligature-bracket-engraver.cc | 4 +- lily/ligature-engraver.cc | 4 +- lily/lily-guile.cc | 14 +- lily/lily-lexer.cc | 4 +- lily/lily-parser.cc | 8 +- lily/lilypond-version.cc | 4 +- lily/line-interface.cc | 10 +- lily/lookup.cc | 14 +- lily/lyric-extender.cc | 2 +- lily/lyric-performer.cc | 2 +- lily/main.cc | 6 +- lily/melody-spanner.cc | 6 +- lily/mensural-ligature-engraver.cc | 22 +- lily/midi-walker.cc | 2 +- lily/misc.cc | 6 +- lily/multi-measure-rest-engraver.cc | 16 +- lily/new-fingering-engraver.cc | 49 ++-- lily/note-collision.cc | 71 +++-- lily/note-column.cc | 4 +- lily/note-heads-engraver.cc | 8 +- lily/note-name-engraver.cc | 6 +- lily/note-performer.cc | 6 +- lily/note-spacing.cc | 8 +- lily/ottava-bracket.cc | 4 +- lily/output-property-engraver.cc | 4 +- lily/pango-select.cc | 3 +- lily/paper-book.cc | 2 +- lily/paper-column-engraver.cc | 4 +- lily/paper-column.cc | 2 +- lily/paper-score.cc | 8 +- lily/performance.cc | 4 +- lily/performer-group.cc | 4 +- lily/phrasing-slur-engraver.cc | 14 +- lily/piano-pedal-bracket.cc | 3 +- lily/piano-pedal-engraver.cc | 8 +- lily/piano-pedal-performer.cc | 6 +- lily/pitched-trill-engraver.cc | 6 +- lily/pointer-group-interface.cc | 4 +- lily/program-option.cc | 6 +- lily/relocate.cc | 12 +- lily/rest-collision-engraver.cc | 6 +- lily/rest-collision.cc | 24 +- lily/rhythmic-column-engraver.cc | 6 +- lily/score-engraver.cc | 6 +- lily/score-performer.cc | 2 +- lily/score-scheme.cc | 6 +- lily/score.cc | 8 +- lily/script-column-engraver.cc | 4 +- lily/script-column.cc | 6 +- lily/script-engraver.cc | 10 +- lily/separating-group-spanner.cc | 2 +- lily/separating-line-group-engraver.cc | 4 +- lily/separation-item.cc | 6 +- lily/side-position-interface.cc | 2 +- lily/simple-spacer-scheme.cc | 12 +- lily/simple-spacer.cc | 28 +- lily/skyline.cc | 38 +-- lily/slur-configuration.cc | 22 +- lily/slur-engraver.cc | 17 +- lily/slur-scoring.cc | 44 +-- lily/slur.cc | 9 +- lily/source-file.cc | 15 +- lily/spacing-determine-loose-columns.cc | 28 +- lily/spacing-engraver.cc | 12 +- lily/spacing-loose-columns.cc | 12 +- lily/spacing-spanner.cc | 20 +- lily/span-arpeggio-engraver.cc | 8 +- lily/span-bar-engraver.cc | 6 +- lily/span-bar.cc | 12 +- lily/span-dynamic-performer.cc | 20 +- lily/spanner.cc | 12 +- lily/staff-spacing.cc | 6 +- lily/stanza-number-align-engraver.cc | 8 +- lily/stem.cc | 18 +- lily/system-start-delimiter-engraver.cc | 18 +- lily/system-start-delimiter.cc | 2 +- lily/system.cc | 50 ++-- lily/tab-note-heads-engraver.cc | 10 +- lily/text-engraver.cc | 12 +- lily/tfm-reader.cc | 10 +- lily/tfm.cc | 2 +- lily/tie-column.cc | 2 +- lily/tie-engraver.cc | 18 +- lily/tie-formatting-problem.cc | 100 +++---- lily/tie-performer.cc | 8 +- lily/translator-dispatch-list.cc | 4 +- lily/translator-group.cc | 6 +- lily/translator.cc | 8 +- lily/tuplet-bracket.cc | 30 +- lily/tuplet-engraver.cc | 18 +- lily/vaticana-ligature-engraver.cc | 12 +- lily/vertical-align-engraver.cc | 2 +- lily/volta-bracket.cc | 4 +- 217 files changed, 1726 insertions(+), 1304 deletions(-) create mode 100644 flower/include/std-vector.hh diff --git a/ChangeLog b/ChangeLog index 5dfd79407e..c3e75d3c2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-01-31 Jan Nieuwenhuizen + + * configure.in (--enable-std-vector): New option. + (--enable-std-string): On by default. + + * flower/include/std-vector.hh: New file. Enable switch to + std::vector, update client code. + 2006-01-30 Graham Percival * scm/document-translation.scm: clarify "this context is also diff --git a/configure.in b/configure.in index d2818093a7..e9047ff59c 100644 --- a/configure.in +++ b/configure.in @@ -33,9 +33,9 @@ AC_ARG_ENABLE(gui, [ --enable-gui compile with experimental GNOME output. Default: off], [gui_b=$enableval]) -std_string=no +std_string=yes AC_ARG_ENABLE(std-string, - [ --enable-std-string compile with experimental std::string. Default: off], + [ --enable-std-string compile with std::string. Default: on], [std_string=$enableval]) if test "$std_string" = "yes"; then # Store in config.make rather than in config.hh and have every @@ -43,6 +43,16 @@ if test "$std_string" = "yes"; then DEFINES="$DEFINES -DSTD_STRING=1" fi +std_vector=no +AC_ARG_ENABLE(std-string, + [ --enable-std-vector compile with experimental std::vector. Default: off], + [std_vector=$enableval]) +if test "$std_vector" = "yes"; then + # Store in config.make rather than in config.hh and have every + # source file depend on that. + DEFINES="$DEFINES -DSTD_VECTOR=1" +fi + NCSB_DIR=unknown AC_ARG_WITH(ncsb-dir, [ --with-ncsb-dir=DIR location of Century Schoolbook fonts diff --git a/flower/file-path.cc b/flower/file-path.cc index ff35abfaec..a25128213d 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -31,7 +31,7 @@ using namespace std; #define PATHSEP ':' #endif -Array +std::vector File_path::directories () const { return dirs_; @@ -130,7 +130,7 @@ File_path::find (std::string name) const if (file_name.dir_[0] == DIRSEP && is_file (file_name.to_string ())) return file_name.to_string (); - for (int i = 0; i < dirs_.size (); i++) + for (vsize i = 0; i < dirs_.size (); i++) { File_name file_name (name); File_name dir = (std::string) dirs_[i]; @@ -194,7 +194,7 @@ std::string File_path::to_string () const { std::string s; - for (int i = 0; i < dirs_.size (); i++) + for (vsize i = 0; i < dirs_.size (); i++) { s = s + dirs_[i]; if (i < dirs_.size () - 1) @@ -206,7 +206,7 @@ File_path::to_string () const void File_path::append (std::string str) { - dirs_.push (str); + dirs_.push_back (str); } void diff --git a/flower/include/array.hh b/flower/include/array.hh index 5b398f28e3..400aeea233 100644 --- a/flower/include/array.hh +++ b/flower/include/array.hh @@ -6,6 +6,10 @@ #ifndef ARRAY_H #define ARRAY_H +#ifndef STD_VECTOR_HH +#error array.hh is obsolete, use std-vector.hh +#endif + #include using namespace std; @@ -13,6 +17,7 @@ using namespace std; #define INLINE inline #endif +namespace std { /// copy a bare (C-)array from #src# to #dest# sized #count# template void arrcpy (T *dest, T const *src, int count); @@ -35,13 +40,13 @@ class Array { protected: /// maximum length of array. - int max_; + vsize max_; /// the data itself T *array_; /// stretch or shrink array. - void remax (int newmax) + void remax (vsize newmax) { T *newarr = new T[newmax]; size_ = (newmax < size_) ? newmax : size_; @@ -51,9 +56,61 @@ protected: array_ = newarr; max_ = newmax; } - int size_; + vsize size_; public: + /* std::vector interface */ + Array () + { + array_ = 0; + max_ = 0; + size_ = 0; + } + + Array (Array const &src) + { + array_ = src.copys (); + max_ = size_ = src.size_; + } + + T const &back () const + { + return (*this)[size_ - 1]; + } + + T &back () + { + return (*this)[size_ - 1]; + } + + bool empty () const + { + return !size_; + } + + void pop_back () + { + assert (!empty ()); + resize (size () - 1); + } + + vsize size () const + { + return size_; + } + + /** set the size_ to #s#. + POST: size () == s. + Warning: contents are unspecified */ + void resize (vsize s) + { + if (s > max_) + remax (s); + size_ = s; + } + + + /// check invariants void OK () const; /** report the size_. @@ -61,45 +118,36 @@ public: {setsize_} */ - int size () const - { - return size_; - } - /// POST: size () == 0 void clear () { size_ = 0; } - Array (T *tp, int n) + Array (T *tp, vsize n) { array_ = new T[n]; max_ = size_ = n; arrcpy (array_, tp, n); } - Array () - { array_ = 0; max_ = 0; size_ = 0; } - // ugh, get around gcc 2.8.1 ice; see bezier.cc - Array (int i) + Array (vsize i) { max_ = size_ = i; array_ = new T[i]; } - /** set the size_ to #s#. - POST: size () == s. - Warning: contents are unspecified */ - void set_size (int s) + /// tighten array size_. + void tighten_maxsize () { - if (s > max_) remax (s); - size_ = s; + remax (size_); } ~Array () - { delete[] array_; } + { + delete[] array_; + } /// return a "new"ed copy of array T *copys () const @@ -115,47 +163,40 @@ public: } void operator = (Array const &src) { - set_size (src.size_); + resize (src.size_); arrcpy (array_, src.array_, size_); } - Array (Array const &src) - { - array_ = src.copys (); - max_ = size_ = src.size_; - } - - /// tighten array size_. - void tighten_maxsize () - { - remax (size_); - } T *remove_array (); /// access element - T &operator [] (int i) + T &operator [] (vsize i) { return elem_ref (i); } /// access element - T const &operator [] (int i) const + T const &operator [] (vsize i) const { return elem_ref (i); } /// access element - T &elem_ref (int i) const + T &elem_ref (vsize i) const { +#if !STD_VECTOR assert (i >= 0 && i < size_); +#else + assert (i < size_); +#endif return ((T *)array_)[i]; } /// access element - T elem (int i) const + T elem (vsize i) const { return elem_ref (i); } /// add to the end of array - void push (T x) + void push_back (T x) { if (size_ == max_) remax (2 * max_ + 1); @@ -164,26 +205,29 @@ public: // vars array_[size_++] = x; } +#if 0 /// remove and return last entry T pop () { - assert (!is_empty ()); + assert (!empty ()); T l = top (0); - set_size (size () - 1); + resize (size () - 1); return l; } +#endif + /// access last entry - T &top (int j = 0) + T &top (vsize j) { return (*this)[size_ - j - 1]; } /// return last entry - T top (int j = 0) const + T top (vsize j) const { return (*this)[size_ - j - 1]; } - T &boundary (int dir, int idx) + T &boundary (int dir, vsize idx) { assert (dir); if (dir == 1) @@ -191,7 +235,7 @@ public: else return elem_ref (idx); } - T boundary (int dir, int idx) const + T boundary (int dir, vsize idx) const { assert (dir); if (dir == 1) @@ -199,46 +243,48 @@ public: else return elem (idx); } - void swap (int i, int j) + void swap (vsize i, vsize j) { T t ((*this)[i]); (*this)[i] = (*this)[j]; (*this)[j] = t; } - bool is_empty () const - { return !size_; } - void insert (T k, int j); + void insert (T k, vsize j); /** remove i-th element, and return it. */ - T get (int i) + T get (vsize i) { T t = elem (i); del (i); return t; } - void unordered_del (int i) + void unordered_del (vsize i) { - elem_ref (i) = top (); - set_size (size () -1); + elem_ref (i) = back (); + resize (size () -1); } - void del (int i) + void del (vsize i) { - assert (i >= 0&& i < size_); +#if !STD_VECTOR + assert (i >= 0 && i < size_); +#else + assert (i < size_); +#endif arrcpy (array_ + i, array_ + i + 1, size_ - i - 1); size_--; } // quicksort. void sort (int (*compare) (T const &, T const &), - int lower = -1, int upper = -1); + vsize lower=VPOS, vsize upper=VPOS); void concat (Array const &src) { - int s = size_; - set_size (size_ + src.size_); + vsize s = size_; + resize (size_ + src.size_); arrcpy (array_ + s, src.array_, src.size_); } - Array slice (int lower, int upper) const; + Array slice (vsize lower, vsize upper) const; void reverse (); }; @@ -255,4 +301,6 @@ int default_compare (T const &a, T const &b) #include "array.icc" +} + #endif diff --git a/flower/include/array.icc b/flower/include/array.icc index e8c201466f..3b6c27945c 100644 --- a/flower/include/array.icc +++ b/flower/include/array.icc @@ -5,7 +5,7 @@ */ #if 0 -#include "array.hh" +#include "std-vector.hh" #ifdef INLINE #undef INLINE #endif @@ -18,9 +18,9 @@ */ template INLINE void -arrcpy (T *dest, T const *src, int count) +arrcpy (T *dest, T const *src, vsize count) { - for (int i_shadows_local = 0; i_shadows_local < count; i_shadows_local++) + for (vsize i_shadows_local = 0; i_shadows_local < count; i_shadows_local++) #ifdef __powerpc__ { /* @@ -38,17 +38,21 @@ arrcpy (T *dest, T const *src, int count) } template INLINE void -Array::insert (T k, int j) +Array::insert (T k, vsize j) { - assert (j >= 0 && j <= size_); - set_size (size_ + 1); - for (int i = size_ - 1; i > j; i--) +#if !STD_VECTOR + assert (j >= 0 && j <= size_); +#else + assert (j <= size_); +#endif + resize (size_ + 1); + for (vsize i = size_ - 1; i > j; i--) array_[i] = array_[i - 1]; array_[j] = k; } template INLINE void -Array::sort (int (*compare) (T const &, T const &), int lower, int upper) +Array::sort (int (*compare) (T const &, T const &), vsize lower, vsize upper) { if (lower < 0) { @@ -58,8 +62,8 @@ Array::sort (int (*compare) (T const &, T const &), int lower, int upper) if (lower >= upper) return; swap (lower, (lower + upper) / 2); - int last = lower; - for (int i = lower +1; i <= upper; i++) + vsize last = lower; + for (vsize i = lower +1; i <= upper; i++) if (compare (array_[i], array_[lower]) < 0) swap (++last, i); swap (lower, last); @@ -70,8 +74,8 @@ Array::sort (int (*compare) (T const &, T const &), int lower, int upper) template INLINE void Array::reverse () { - int h = size_ / 2; - for (int i = 0, j = size_ - 1; i < h; i++, j--) + vsize h = size_ / 2; + for (vsize i = 0, j = size_ - 1; i < h; i++, j--) swap (i, j); } @@ -79,7 +83,11 @@ template INLINE void Array::OK () const { +#if !STD_VECTOR assert (max_ >= size_ && size_ >= 0); +#else + assert (max_ >= size_); +#endif if (max_) assert (array_); } @@ -97,12 +105,16 @@ Array::remove_array () template INLINE Array -Array::slice (int lower, int upper) const +Array::slice (vsize lower, vsize upper) const { +#if !STD_VECTOR assert (lower >= 0 && lower <= upper && upper <= size_); +#else + assert (lower <= upper && upper <= size_); +#endif Array r; - int s = upper - lower; - r.set_size (s); + vsize s = upper - lower; + r.resize (s); arrcpy (r.array_, array_ + lower, s); return r; } @@ -111,8 +123,8 @@ template void binary_search_bounds (Array const &table, T const &key, int (*compare) (T const &, T const &), - int *lo, - int *hi) + vsize *lo, + vsize *hi) { int cmp; int result; @@ -136,19 +148,20 @@ binary_search_bounds (Array const &table, lookup with binsearch, return array index. */ template -int +vsize binary_search (Array const &table, T const &key, int (*compare) (T const &, T const &), - int lo = 0, - int hi = -1) + vsize lo=0, + vsize hi=VPOS) { - if (hi < 0) + if (hi == VPOS) hi = table.size (); binary_search_bounds (table, key, compare, &lo, &hi); if (! (*compare) (key, table[lo])) return lo; - else - return -1; /* not found */ + + /* not found */ + return VPOS; } diff --git a/flower/include/file-name.hh b/flower/include/file-name.hh index 329a972c9f..3d3a442f54 100644 --- a/flower/include/file-name.hh +++ b/flower/include/file-name.hh @@ -9,7 +9,7 @@ #ifndef FILE_NAME_HH #define FILE_NAME_HH -#include "array.hh" +#include "std-vector.hh" #include "std-string.hh" class File_name diff --git a/flower/include/file-path.hh b/flower/include/file-path.hh index 22b943e9c8..9379eda5ad 100644 --- a/flower/include/file-path.hh +++ b/flower/include/file-path.hh @@ -9,7 +9,7 @@ #ifndef FILE_PATH_HH #define FILE_PATH_HH -#include "array.hh" +#include "std-vector.hh" #include "std-string.hh" /** @@ -23,9 +23,10 @@ class File_path { - Array dirs_; + std::vector dirs_; + public: - Array directories () const; + std::vector directories () const; std::string find (std::string name) const; std::string find (std::string name, char const *extensions[]); std::string to_string () const; diff --git a/flower/include/flower-proto.hh b/flower/include/flower-proto.hh index f175eebb1a..66bd2648c1 100644 --- a/flower/include/flower-proto.hh +++ b/flower/include/flower-proto.hh @@ -10,26 +10,28 @@ char const *flower_version_str0 (); -template struct Link_array; -template struct Array; template struct Assoc; template struct Hash_table; template struct Hash_table_iter; -template struct Link_list; -template struct Interval_t; -template struct PQueue; typedef unsigned char Byte; namespace std { struct String_data; struct String_handle; - //struct String; } struct String_convert; #include "std-string.hh" +#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; + + typedef Interval_t Interval; struct Offset; diff --git a/flower/include/guile-compatibility.hh b/flower/include/guile-compatibility.hh index c256ddfc31..3b27b579ec 100644 --- a/flower/include/guile-compatibility.hh +++ b/flower/include/guile-compatibility.hh @@ -52,6 +52,8 @@ inline int ly_c_number_p (SCM x) { return SCM_NUMBERP (x); } #define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T) inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); } #define scm_to_int(x) (ly_scm2int (x)) +inline int ly_scm2unsigned (SCM x) { return scm_num2uint (x, 0, "ly_scm2unsigned"); } +#define scm_to_unsigned(x) (ly_scm2unsigned (x)) inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); } #define scm_is_symbol(x) ly_c_symbol_p (x) inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); } @@ -69,6 +71,11 @@ inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); } #define scm_to_double(x) (ly_scm2double (x)) #define scm_from_double(x) (scm_make_real (x)) -#endif /* SCM_MINOR_VERSION < 7 */ +#else /* !SCM_MINOR_VERSION < 7 */ + +#define scm_to_unsigned(x) scm_to_uint32 (x) +#define scm_from_unsigned(x) scm_from_unsigned_integer (x) + +#endif /* !SCM_MINOR_VERSION < 7 */ #endif /* GUILE_COMPATIBILITY_HH */ diff --git a/flower/include/interval-set.hh b/flower/include/interval-set.hh index 4c0ba0ac6a..6a6ad9e3cb 100644 --- a/flower/include/interval-set.hh +++ b/flower/include/interval-set.hh @@ -9,7 +9,7 @@ #ifndef INTERVAL_SET_HH #define INTERVAL_SET_HH -#include "array.hh" +#include "std-vector.hh" #include "interval.hh" /* @@ -21,7 +21,7 @@ */ struct Interval_set { - Array allowed_regions_; + std::vector allowed_regions_; Interval_set (); void set_full (); diff --git a/flower/include/parray.hh b/flower/include/parray.hh index d7a4afba00..4378dda8b8 100644 --- a/flower/include/parray.hh +++ b/flower/include/parray.hh @@ -9,7 +9,7 @@ #ifndef PARRAY_HH #define PARRAY_HH -#include "array.hh" +#include "std-vector.hh" /** an array of pointers. @@ -25,9 +25,32 @@ class Link_array : private Array :Array (v) { } + public: Link_array () - {} + { + } + + T *const &back() const + { + return (T * const &) Array::back(); + } + + T *&back () + { + return (T *&) Array::back (); + } + + /* Flower compat */ + Array::del; + Array::unordered_del; + Array::size; + Array::clear; + Array::resize; + Array::empty; + Array::reverse; + Array::pop_back; + Array::tighten_maxsize; static int default_compare (T *const &p1, T *const &p2) { @@ -69,25 +92,29 @@ public: } T *pop () { - return (T *) Array::pop (); + T* t = (T *) Array::back (); + pop_back (); + return t; } - void insert (T *t, int i) + void insert (T *t, vsize i) { Array::insert (t, i); } - void push (T *t) + void push_back (T *t) { - Array::push (t); + Array::push_back (t); } + /// return last entry - T *top (int j = 0) const + T *top (int j) const { return (T *) Array::top (j); } - T *& top (int i = 0) + T *& top (int i) { return (T *&) Array::top (i); } + void substitute (T *old, T *new_p) { int i; @@ -117,19 +144,11 @@ public: void uniq () { Link_array ls; - for (int i = 0; i < size (); i++) + for (vsize i = 0; i < size (); i++) if (!i || elem (i - 1) != elem (i)) - ls.push (elem (i)); + ls.push_back (elem (i)); *this = ls; } - Array::del; - Array::unordered_del; - Array::size; - Array::clear; - Array::set_size; - Array::is_empty; - Array::reverse; - Array::tighten_maxsize; T *& boundary (int d, int i) { @@ -167,7 +186,7 @@ public: } int find_index (T const *t) const { - for (int i = 0; i < size (); i++) + for (vsize i = 0; i < size (); i++) if (elem (i) == t) return i; return -1; @@ -187,8 +206,8 @@ Link_array typecasts (Link_array const &a, T * /* dummy */) { Link_array ret; - for (int i = a.size (); i--;) - ret.push (dynamic_cast (a[i])); // ugh? + for (vsize i = a.size (); i--;) + ret.push_back (dynamic_cast (a[i])); // ugh? return ret; } @@ -216,7 +235,7 @@ template void junk_pointers (Link_array &a) { - for (int i = 0; i < a.size (); i++) + for (vsize i = 0; i < a.size (); i++) delete a[i]; a.clear (); } diff --git a/flower/include/polynomial.hh b/flower/include/polynomial.hh index 6c509fa53a..c3bbc17d6c 100644 --- a/flower/include/polynomial.hh +++ b/flower/include/polynomial.hh @@ -8,7 +8,7 @@ #ifndef POLY_H #define POLY_H -#include "array.hh" +#include "std-vector.hh" #include "arithmetic-operator.hh" #include "real.hh" @@ -19,7 +19,7 @@ struct Polynomial int degree ()const; /// coefficients - Array coefs_; + std::vector coefs_; // leading coef Real &lc (); @@ -28,8 +28,8 @@ struct Polynomial Real lc () const; void print () const; Real eval (Real) const; - void print_sols (Array) const; - void check_sols (Array) const; + void print_sols (std::vector) const; + void check_sols (std::vector) const; void check_sol (Real x) const; static Polynomial multiply (const Polynomial &p1, const Polynomial &p2); static Polynomial power (int exponent, const Polynomial &src); @@ -55,11 +55,11 @@ struct Polynomial void debug_clean (); - Array solve_quadric ()const; - Array solve_cubic ()const; - Array solve_linear ()const; + std::vector solve_quadric ()const; + std::vector solve_cubic ()const; + std::vector solve_linear ()const; - Array solve () const; + std::vector solve () const; }; IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, -); diff --git a/flower/include/pqueue.hh b/flower/include/pqueue.hh index a50caefaaf..2f1896f42a 100644 --- a/flower/include/pqueue.hh +++ b/flower/include/pqueue.hh @@ -8,7 +8,7 @@ #ifndef PQUEUE_HH #define PQUEUE_HH -#include "array.hh" +#include "std-vector.hh" template struct PQueue_ent @@ -35,11 +35,11 @@ template class PQueue { Array heap_array_; - T &elt (int i) + T &elt (vsize i) { return heap_array_[i - 1]; } - T const &elt (int i) const + T const &elt (vsize i) const { return heap_array_[i - 1]; } @@ -48,22 +48,34 @@ public: priority might fuck up the invariants @param 1 <= i < size () */ - T &operator [] (int i) { return heap_array_[i]; } - T operator [] (int i) const { return heap_array_[i]; } + T &operator [] (vsize i) + { + return heap_array_[i]; + } + T operator [] (vsize i) const + { + return heap_array_[i]; + } void OK () const { #ifndef NDEBUG - for (int i = 2; i <= size (); i++) + for (vsize i = 2; i <= size (); i++) assert (compare (elt (i / 2), elt (i)) <= 0); #endif } - T front () const { return elt (1); } - int size () const { return heap_array_.size (); } + T front () const + { + return elt (1); + } + vsize size () const + { + return heap_array_.size (); + } void insert (T v) { - heap_array_.push (v); - int i = heap_array_.size (); - int j = i / 2; + heap_array_.push_back (v); + vsize i = heap_array_.size (); + vsize j = i / 2; while (j) { if (compare (elt (j), v) > 0) @@ -87,10 +99,10 @@ public: void delmin () { assert (size ()); - T last = heap_array_.top (); + T last = heap_array_.back (); - int mini = 2; - int lasti = 1; + vsize mini = 2; + vsize lasti = 1; while (mini < size ()) { @@ -103,7 +115,7 @@ public: mini *= 2; } elt (lasti) = last; - heap_array_.pop (); + heap_array_.pop_back (); OK (); } T get () diff --git a/flower/include/std-string.hh b/flower/include/std-string.hh index c07ffdfac1..53b02c2cca 100644 --- a/flower/include/std-string.hh +++ b/flower/include/std-string.hh @@ -56,7 +56,8 @@ namespace std { string to_string (char c, int n = 1); string to_string (int i, char const *format = 0); string to_string (double f, char const *format = 0); - string to_string (long b); + string to_string (long); + string to_string (unsigned); string to_string (bool b); string to_string (char const *format, ...); diff --git a/flower/include/std-vector.hh b/flower/include/std-vector.hh new file mode 100644 index 0000000000..8fda47c8b2 --- /dev/null +++ b/flower/include/std-vector.hh @@ -0,0 +1,293 @@ +/* + std-vector.hh -- declare std::vector + + source file of the GNU LilyPond music typesetter + + (c) 2006 Jan Nieuwenhuizen +*/ + +#ifndef STD_VECTOR_HH +#define STD_VECTOR_HH + +#include // reverse, sort + +#if !STD_VECTOR +/* Also declare vector, in the wrong way. */ +#include +#include +#include +#endif + + +#include "compare.hh" + +#if STD_VECTOR + +#define vector __vector +#include +#undef vector + +namespace std { + + #ifndef VSIZE + #define VSIZE + typedef size_t vsize; + #define VPOS UINT_MAX + #endif + + /* Interface without pointer arithmetic (iterator) semantics. */ + template + class vector : public __vector + { + public: + typedef typename __vector::iterator iterator; + //typedef int (*compare) (T *const&, T *const&); + + vector () : __vector () + { + } + + vector (iterator const b, iterator const e) : __vector (b, e) + { + } + + vector (vsize b, vsize e) : __vector (iter (b), iter (e)) + { + } + + iterator iter (vsize n) + { + if (n == VPOS) + return this->end (); + return __vector::begin () + n; + } + + iterator const iter (vsize n) const + { + if (n == VPOS) + return this->end (); + return __vector::begin () + n; + } + + void + insert (T k, vsize i) + { + __vector::insert (this->iter (i), k); + } + + void + insert (vector &v, vsize i) + { + __vector::insert (iter (i), v.begin (), v.end ()); + } + + void + concat (vector const &v) + { + __vector::insert (this->end (), v.begin (), v.end ()); + } + + /* Flower-Array compatibility. */ + T const & + boundary (int dir, vsize i) const + { + assert (dir); + if (dir == 1) + return this->top (i); + else + return this->at (i); + } + + T & + boundary (int dir, vsize i) + { + assert (dir); + if (dir == 1) + return this->top (i); + else + return this->at (i); + } + + T + del (vsize i) + { + return *__vector::erase (iter (i)); + } + + T const & + elem (vsize i) const + { + return this->at (i); + } + + T & + elem (vsize i) + { + return this->at (i); + } + +#if 1 // FIXME, silly, but keep for s/r + T const & + elem_ref (vsize i) const + { + return elem (i); + } + + T & + elem_ref (vsize i) + { + return elem (i); + } +#endif + +#if 0 + T * + remove_array () + { + // FIXME, no algorithm for this? + T *p = new T[this->size ()]; + for (vsize i = 0; i < this->size (); i++) + p[i] = (*this)[i]; + this->clear (); + return p; + } +#else + T * + remove_array () + { + T *p = &(*this)[0]; + // forget array? + //this->resize (0); + return p; + } +#endif + + void + reverse () + { + // CHECKME: for a simple vector, like vector, this should + // expand to memrev. + ::std::reverse (this->begin (), this->end ()); + } + + vector + slice (vsize b, vsize e) const + { + return vector (b, e); + } + + void + sort (int vsize=VPOS, vsize b=VPOS, vsize e=VPOS) + { + ::std::sort (iter (b), iter(e)); + } + + void + sort (int (*compare) (T const &, T const &), int b=-1, int e=-1) + { + ::std::sort (iter (b), iter(e), compare); + } + + void swap (vsize i, vsize j) + { + T t ((*this)[i]); + (*this)[i] = (*this)[j]; + (*this)[j] = t; + } + + T const & + top (vsize i) const + { + return (*this)[this->size () - i - 1]; + } + + T& + top (vsize i) + { + return (*this)[this->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) compare; + vector::iterator const i = find (v.iter (b), v.iter (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 + void + binary_search_bounds (vector const &table, + T const &key, int (*compare) (T const &, T const &), + vsize *lo, + vsize *hi) + { + int cmp; + int result; + + /* binary search */ + do + { + cmp = (*lo + *hi) / 2; + + result = (*compare) (key, table[cmp]); + + if (result < 0) + *hi = cmp; + else + *lo = cmp; + } + while (*hi - *lo > 1); + } + + 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 (); + + binary_search_bounds (table, key, compare, &lo, &hi); + + if (! (*compare) (key, table[lo])) + return lo; + + /* not found */ + return VPOS; + } +#endif +} + + + +#else /* ! STD_VECTOR */ + +namespace std { + +#define vector Array + using namespace std; + + #ifndef VSIZE + #define VSIZE + typedef int vsize; + #define VPOS -1 + #endif +} + + +#endif /* STD_VECTOR */ + +#include "array.hh" + +#endif /* STD_VECTOR_HH */ diff --git a/flower/include/string-convert.hh b/flower/include/string-convert.hh index 198e365b96..c7ba970266 100644 --- a/flower/include/string-convert.hh +++ b/flower/include/string-convert.hh @@ -37,6 +37,7 @@ public: static unsigned hex2unsigned (std::string str); static std::string hex2bin (std::string str); static std::string int_string (int i, char const *fmt = 0); + static std::string unsigned_string (unsigned); static std::string long_string (long); static std::string int2hex (int i, int length_i, char ch); static std::string unsigned2hex (unsigned u, ssize length, char ch); @@ -44,7 +45,7 @@ public: static std::string rational_string (Rational); static std::string pointer_string (void const *); static std::string precision_string (double x, int n); - static Array split (std::string str, char c); + static std::vector split (std::string str, char c); static std::string i64_string (I64, char const *fmt = 0); static std::string to_lower (std::string s); static std::string to_upper (std::string s); diff --git a/flower/interval-set.cc b/flower/interval-set.cc index 89e5188830..7c8bd0e6a1 100644 --- a/flower/interval-set.cc +++ b/flower/interval-set.cc @@ -27,13 +27,13 @@ Interval_set::set_full () allowed_regions_.clear (); Interval s; s.set_full (); - allowed_regions_.push (s); + allowed_regions_.push_back (s); } void Interval_set::remove_interval (Interval rm) { - for (int i = 0; i < allowed_regions_.size ();) + for (vsize i = 0; i < allowed_regions_.size ();) { Interval s = rm; diff --git a/flower/polynomial.cc b/flower/polynomial.cc index d9b4cf1690..4d9687de38 100644 --- a/flower/polynomial.cc +++ b/flower/polynomial.cc @@ -22,7 +22,7 @@ Polynomial::eval (Real x) const Real p = 0.0; // horner's scheme - for (int i = coefs_.size (); i--;) + for (vsize i = coefs_.size (); i--;) p = x * p + coefs_[i]; return p; @@ -36,10 +36,10 @@ Polynomial::multiply (const Polynomial &p1, const Polynomial &p2) int deg = p1.degree () + p2.degree (); for (int i = 0; i <= deg; i++) { - dest.coefs_.push (0); + dest.coefs_.push_back (0); for (int j = 0; j <= i; j++) if (i - j <= p2.degree () && j <= p1.degree ()) - dest.coefs_.top () += p1.coefs_[j] * p2.coefs_[i - j]; + dest.coefs_.back () += p1.coefs_[j] * p2.coefs_[i - j]; } return dest; @@ -50,7 +50,7 @@ Polynomial::differentiate () { for (int i = 1; i <= degree (); i++) coefs_[i - 1] = coefs_[i] * i; - coefs_.pop (); + coefs_.pop_back (); } Polynomial @@ -88,16 +88,16 @@ Polynomial::clean () We only do relative comparisons. Absolute comparisons break down in degenerate cases. */ while (degree () > 0 - && (fabs (coefs_.top ()) < FUDGE * fabs (coefs_.top (1)) - || !coefs_.top ())) - coefs_.pop (); + && (fabs (coefs_.back ()) < FUDGE * fabs (coefs_.top (1)) + || !coefs_.back ())) + coefs_.pop_back (); } void Polynomial::operator += (Polynomial const &p) { while (degree () < p.degree ()) - coefs_.push (0.0); + coefs_.push_back (0.0); for (int i = 0; i <= p.degree (); i++) coefs_[i] += p.coefs_[i]; @@ -107,7 +107,7 @@ void Polynomial::operator -= (Polynomial const &p) { while (degree () < p.degree ()) - coefs_.push (0.0); + coefs_.push_back (0.0); for (int i = 0; i <= p.degree (); i++) coefs_[i] -= p.coefs_[i]; @@ -154,7 +154,7 @@ Polynomial::set_mod (const Polynomial &u, const Polynomial &v) while (k >= 0 && coefs_[k] == 0.0) k--; - coefs_.set_size (1+ ((k < 0) ? 0 : k)); + coefs_.resize (1+ ((k < 0) ? 0 : k)); return degree (); } @@ -174,17 +174,17 @@ Polynomial::check_sol (Real x) const } void -Polynomial::check_sols (Array roots) const +Polynomial::check_sols (std::vector roots) const { - for (int i = 0; i < roots.size (); i++) + for (vsize i = 0; i < roots.size (); i++) check_sol (roots[i]); } Polynomial::Polynomial (Real a, Real b) { - coefs_.push (a); + coefs_.push_back (a); if (b) - coefs_.push (b); + coefs_.push_back (b); } /* cubic root. */ @@ -203,10 +203,10 @@ iszero (Real r) return !r; } -Array +std::vector Polynomial::solve_cubic ()const { - Array sol; + std::vector sol; /* normal form: x^3 + Ax^2 + Bx + C = 0 */ Real A = coefs_[2] / coefs_[3]; @@ -229,15 +229,15 @@ Polynomial::solve_cubic ()const if (iszero (D)) { if (iszero (q)) { /* one triple solution */ - sol.push (0); - sol.push (0); - sol.push (0); + sol.push_back (0); + sol.push_back (0); + sol.push_back (0); } else { /* one single and one double solution */ Real u = cubic_root (-q); - sol.push (2 * u); - sol.push (-u); + sol.push_back (2 * u); + sol.push_back (-u); } } else if (D < 0) @@ -246,9 +246,9 @@ Polynomial::solve_cubic ()const Real phi = 1.0 / 3 * acos (-q / sqrt (-cb)); Real t = 2 * sqrt (-p); - sol.push (t * cos (phi)); - sol.push (-t * cos (phi + M_PI / 3)); - sol.push (-t * cos (phi - M_PI / 3)); + sol.push_back (t * cos (phi)); + sol.push_back (-t * cos (phi + M_PI / 3)); + sol.push_back (-t * cos (phi - M_PI / 3)); } else { @@ -257,13 +257,13 @@ Polynomial::solve_cubic ()const Real u = cubic_root (sqrt_D - q); Real v = -cubic_root (sqrt_D + q); - sol.push (u + v); + sol.push_back (u + v); } /* resubstitute */ Real sub = 1.0 / 3 * A; - for (int i = sol.size (); i--;) + for (vsize i = sol.size (); i--;) { sol[i] -= sub; @@ -278,13 +278,13 @@ Polynomial::solve_cubic ()const Real Polynomial::lc () const { - return coefs_.top (); + return coefs_.back (); } Real & Polynomial::lc () { - return coefs_.top (); + return coefs_.back (); } int @@ -295,10 +295,10 @@ Polynomial::degree ()const /* all roots of quadratic eqn. */ -Array +std::vector Polynomial::solve_quadric ()const { - Array sol; + std::vector sol; /* normal form: x^2 + px + q = 0 */ Real p = coefs_[1] / (2 * coefs_[2]); Real q = coefs_[0] / coefs_[2]; @@ -309,23 +309,23 @@ Polynomial::solve_quadric ()const { D = sqrt (D); - sol.push (D - p); - sol.push (-D - p); + sol.push_back (D - p); + sol.push_back (-D - p); } return sol; } /* solve linear equation */ -Array +std::vector Polynomial::solve_linear ()const { - Array s; + std::vector s; if (coefs_[1]) - s.push (-coefs_[0] / coefs_[1]); + s.push_back (-coefs_[0] / coefs_[1]); return s; } -Array +std::vector Polynomial::solve () const { Polynomial *me = (Polynomial *) this; @@ -340,7 +340,7 @@ Polynomial::solve () const case 3: return solve_cubic (); } - Array s; + std::vector s; return s; } diff --git a/flower/std-string.cc b/flower/std-string.cc index 4644ae3e92..9eea7ca941 100644 --- a/flower/std-string.cc +++ b/flower/std-string.cc @@ -47,6 +47,12 @@ namespace std { return String_convert::long_string (b); } + std::string + to_string (unsigned u) + { + return String_convert::unsigned_string (u); + } + std::string to_string (char const *format, ...) { diff --git a/flower/string-convert.cc b/flower/string-convert.cc index 140c77632d..07aef9f3f4 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -12,7 +12,7 @@ using namespace std; #include "libc-extension.hh" #include "rational.hh" -#include "array.hh" +#include "std-vector.hh" /** A safe length for stringconversion buffers. @@ -318,22 +318,22 @@ String_convert::precision_string (double x, int n) return (sign (x) > 0 ? str : "-" + str); } -Array +std::vector String_convert::split (std::string str, char c) { - Array a; + std::vector a; ssize i = str.find (c); while (i != NPOS) { std::string s = str.substr (0, i); - a.push (s); + a.push_back (s); while (str[++i] == c) ; str = str.substr (i); i = str.find (c); } if (str.length ()) - a.push (str); + a.push_back (str); return a; } @@ -345,6 +345,14 @@ String_convert::long_string (long l) return s; } +std::string +String_convert::unsigned_string (unsigned u) +{ + char s[STRING_BUFFER_LEN]; + sprintf (s, "%ud", u); + return s; +} + std::string String_convert::pad_to (std::string s, int n) { diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 7d97b65d26..2a3af602c1 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -82,7 +82,7 @@ public: Grob *accidental_placement_; - Array accidentals_; + std::vector accidentals_; Link_array ties_; }; @@ -304,13 +304,13 @@ Accidental_engraver::get_bar_number () void Accidental_engraver::process_acknowledged () { - if (accidentals_.size () && !accidentals_.top ().done_) + if (accidentals_.size () && !accidentals_.back ().done_) { SCM accidentals = get_property ("autoAccidentals"); SCM cautionaries = get_property ("autoCautionaries"); int barnum = get_bar_number (); - for (int i = 0; i < accidentals_.size (); i++) + for (vsize i = 0; i < accidentals_.size (); i++) { if (accidentals_[i].done_) continue; @@ -406,9 +406,9 @@ Accidental_engraver::make_standard_accidental (Music *note, We add the accidentals to the support of the arpeggio, so it is put left of the accidentals. */ - for (int i = 0; i < left_objects_.size (); i++) + for (vsize i = 0; i < left_objects_.size (); i++) Side_position_interface::add_support (left_objects_[i], a); - for (int i = 0; i < right_objects_.size (); i++) + for (vsize i = 0; i < right_objects_.size (); i++) Side_position_interface::add_support (a, right_objects_[i]); a->set_parent (support, Y_AXIS); @@ -451,10 +451,10 @@ Accidental_engraver::finalize () void Accidental_engraver::stop_translation_timestep () { - for (int j = ties_.size (); j--;) + for (vsize j = ties_.size (); j--;) { Grob *r = Tie::head (ties_[j], RIGHT); - for (int i = accidentals_.size (); i--;) + for (vsize i = accidentals_.size (); i--;) if (accidentals_[i].head_ == r) { if (Grob *g = accidentals_[i].accidental_) @@ -467,7 +467,7 @@ Accidental_engraver::stop_translation_timestep () } } - for (int i = accidentals_.size (); i--;) + for (vsize i = accidentals_.size (); i--;) { int barnum = get_bar_number (); @@ -544,7 +544,7 @@ Accidental_engraver::acknowledge_rhythmic_head (Grob_info info) entry.origin_ = entry.origin_engraver_->context (); entry.melodic_ = note; - accidentals_.push (entry); + accidentals_.push_back (entry); } } } @@ -552,19 +552,19 @@ Accidental_engraver::acknowledge_rhythmic_head (Grob_info info) void Accidental_engraver::acknowledge_tie (Grob_info info) { - ties_.push (dynamic_cast (info.grob ())); + ties_.push_back (dynamic_cast (info.grob ())); } void Accidental_engraver::acknowledge_arpeggio (Grob_info info) { - left_objects_.push (info.grob ()); + left_objects_.push_back (info.grob ()); } void Accidental_engraver::acknowledge_finger (Grob_info info) { - left_objects_.push (info.grob ()); + left_objects_.push_back (info.grob ()); } void diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index b2ab0ef92c..d6db6f24ef 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -67,9 +67,9 @@ Accidental_placement::split_accidentals (Grob *accs, Grob *a = unsmob_grob (scm_car (s)); if (unsmob_grob (a->get_object ("tie"))) - break_reminder->push (a); + break_reminder->push_back (a); else - real_acc->push (a); + real_acc->push_back (a); } } @@ -94,7 +94,7 @@ Accidental_placement::get_relevant_accidental_extent (Grob *me, which = &ra; Interval extent; - for (int i = 0; i < which->size (); i++) + for (vsize i = 0; i < which->size (); i++) extent.unite (which->elem (i)->extent (item_col, X_AXIS)); if (!extent.is_empty ()) @@ -108,10 +108,10 @@ Accidental_placement::get_relevant_accidental_extent (Grob *me, struct Accidental_placement_entry { - Array left_skyline_; - Array right_skyline_; + std::vector left_skyline_; + std::vector right_skyline_; Interval vertical_extent_; - Array extents_; + std::vector extents_; Link_array grobs_; Real offset_; int notename_; @@ -157,9 +157,8 @@ stagger_apes (Link_array *apes) apes->clear (); - int i = 0; int parity = 1; - while (i < asc.size ()) + for (vsize i = 0; i < asc.size ();) { Accidental_placement_entry *a = 0; if (parity) @@ -167,7 +166,7 @@ stagger_apes (Link_array *apes) else a = asc[i++]; - apes->push (a); + apes->push_back (a); parity = !parity; } @@ -238,9 +237,9 @@ Accidental_placement::calc_positioning_done (SCM smob) ape->notename_ = scm_to_int (scm_caar (s)); for (SCM t = scm_cdar (s); scm_is_pair (t); t = scm_cdr (t)) - ape->grobs_.push (unsmob_grob (scm_car (t))); + ape->grobs_.push_back (unsmob_grob (scm_car (t))); - apes.push (ape); + apes.push_back (ape); } Grob *common[] = {me, 0}; @@ -250,10 +249,10 @@ Accidental_placement::calc_positioning_done (SCM smob) extents if we're sure that we've found the right common refpoint */ Link_array note_cols, heads; - for (int i = apes.size (); i--;) + for (vsize i = apes.size (); i--;) { Accidental_placement_entry *ape = apes[i]; - for (int j = ape->grobs_.size (); j--;) + for (vsize j = ape->grobs_.size (); j--;) { Grob *a = ape->grobs_[j]; @@ -266,9 +265,9 @@ Accidental_placement::calc_positioning_done (SCM smob) Grob *col = head->get_parent (X_AXIS); if (Note_column::has_interface (col)) - note_cols.push (col); + note_cols.push_back (col); else - heads.push (head); + heads.push_back (head); } } @@ -276,7 +275,7 @@ Accidental_placement::calc_positioning_done (SCM smob) This is a little kludgy: to get all notes, we look if there are collisions as well. */ - for (int i = note_cols.size (); i--;) + for (vsize i = note_cols.size (); i--;) { Grob *c = note_cols[i]->get_parent (X_AXIS); if (Note_collision_interface::has_interface (c)) @@ -287,27 +286,27 @@ Accidental_placement::calc_positioning_done (SCM smob) } } - for (int i = note_cols.size (); i--;) + for (vsize i = note_cols.size (); i--;) heads.concat (extract_grob_array (note_cols[i], "note-heads")); heads.default_sort (); heads.uniq (); common[Y_AXIS] = common_refpoint_of_array (heads, common[Y_AXIS], Y_AXIS); - for (int i = apes.size (); i--;) + for (vsize i = apes.size (); i--;) { Accidental_placement_entry *ape = apes[i]; ape->left_skyline_ = empty_skyline (LEFT); ape->right_skyline_ = empty_skyline (RIGHT); - for (int j = apes[i]->grobs_.size (); j--;) + for (vsize j = apes[i]->grobs_.size (); j--;) { Grob *a = apes[i]->grobs_[j]; - Array boxes = Accidental_interface::accurate_boxes (a, common); + std::vector boxes = Accidental_interface::accurate_boxes (a, common); ape->extents_.concat (boxes); - for (int j = boxes.size (); j--;) + for (vsize j = boxes.size (); j--;) { insert_extent_into_skyline (&ape->left_skyline_, boxes[j], Y_AXIS, LEFT); insert_extent_into_skyline (&ape->right_skyline_, boxes[j], Y_AXIS, RIGHT); @@ -316,11 +315,11 @@ Accidental_placement::calc_positioning_done (SCM smob) } Interval total; - for (int i = apes.size (); i--;) + for (vsize i = apes.size (); i--;) { Interval y; - for (int j = apes[i]->extents_.size (); j--;) + for (vsize j = apes[i]->extents_.size (); j--;) y.unite (apes[i]->extents_[j][Y_AXIS]); apes[i]->vertical_extent_ = y; total.unite (y); @@ -330,9 +329,9 @@ Accidental_placement::calc_positioning_done (SCM smob) Accidental_placement_entry *head_ape = new Accidental_placement_entry; common[X_AXIS] = common_refpoint_of_array (heads, common[X_AXIS], X_AXIS); - Array head_skyline (empty_skyline (LEFT)); - Array head_extents; - for (int i = heads.size (); i--;) + std::vector head_skyline (empty_skyline (LEFT)); + std::vector head_extents; + for (vsize i = heads.size (); i--;) { Box b (heads[i]->extent (common[X_AXIS], X_AXIS), heads[i]->extent (common[Y_AXIS], Y_AXIS)); @@ -345,13 +344,13 @@ Accidental_placement::calc_positioning_done (SCM smob) Real padding = robust_scm2double (me->get_property ("padding"), 0.2); - Array left_skyline = head_ape->left_skyline_; + std::vector left_skyline = head_ape->left_skyline_; heighten_skyline (&left_skyline, -robust_scm2double (me->get_property ("right-padding"), 0)); /* Add accs entries right-to-left. */ - for (int i = apes.size (); i-- > 0;) + for (vsize i = apes.size (); i-- > 0;) { Real offset = -skyline_meshing_distance (apes[i]->right_skyline_, left_skyline); @@ -362,27 +361,27 @@ Accidental_placement::calc_positioning_done (SCM smob) apes[i]->offset_ = offset; - Array new_left_skyline = apes[i]->left_skyline_; + std::vector new_left_skyline = apes[i]->left_skyline_; heighten_skyline (&new_left_skyline, apes[i]->offset_); merge_skyline (&new_left_skyline, left_skyline, LEFT); left_skyline = new_left_skyline; } - for (int i = apes.size (); i--;) + for (vsize i = apes.size (); i--;) { Accidental_placement_entry *ape = apes[i]; - for (int j = ape->grobs_.size (); j--;) + for (vsize j = ape->grobs_.size (); j--;) ape->grobs_[j]->translate_axis (ape->offset_, X_AXIS); } Interval left_extent, right_extent; Accidental_placement_entry *ape = apes[0]; - for (int i = ape->extents_.size (); i--;) + for (vsize i = ape->extents_.size (); i--;) left_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]); - ape = apes.top (); - for (int i = ape->extents_.size (); i--;) + ape = apes.back (); + for (vsize i = ape->extents_.size (); i--;) right_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]); left_extent[LEFT] -= robust_scm2double (me->get_property ("left-padding"), 0); @@ -392,7 +391,7 @@ Accidental_placement::calc_positioning_done (SCM smob) me->flush_extent_cache (X_AXIS); me->set_property ("X-extent", scm_width); - for (int i = apes.size (); i--;) + for (vsize i = apes.size (); i--;) delete apes[i]; return SCM_BOOL_T; diff --git a/lily/accidental.cc b/lily/accidental.cc index 94f92f3a72..2996513543 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -52,14 +52,14 @@ Accidental_interface::after_line_breaking (SCM smob) return SCM_UNSPECIFIED; } -Array +std::vector Accidental_interface::accurate_boxes (Grob *a, Grob **common) { Box b; b[X_AXIS] = a->extent (a, X_AXIS); b[Y_AXIS] = a->extent (a, Y_AXIS); - Array boxes; + std::vector boxes; bool parens = false; if (to_boolean (a->get_property ("cautionary"))) @@ -93,8 +93,8 @@ Accidental_interface::accurate_boxes (Grob *a, Grob **common) stem[Y_AXIS] *= 1.1; bulb[Y_AXIS][UP] *= .35; - boxes.push (bulb); - boxes.push (stem); + boxes.push_back (bulb); + boxes.push_back (stem); } break; case NATURAL: @@ -111,9 +111,9 @@ Accidental_interface::accurate_boxes (Grob *a, Grob **common) rstem[X_AXIS][LEFT] = rstem[X_AXIS].linear_combination (1.0 / 3.0); lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; - boxes.push (belly); - boxes.push (lstem); - boxes.push (rstem); + boxes.push_back (belly); + boxes.push_back (lstem); + boxes.push_back (rstem); } break; /* @@ -123,11 +123,11 @@ Accidental_interface::accurate_boxes (Grob *a, Grob **common) } if (!boxes.size ()) - boxes.push (b); + boxes.push_back (b); Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS), a->relative_coordinate (common[Y_AXIS], Y_AXIS)); - for (int i = boxes.size (); i--;) + for (vsize i = boxes.size (); i--;) boxes[i].translate (o); return boxes; diff --git a/lily/align-interface.cc b/lily/align-interface.cc index b9335706d0..85074a4cf3 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -54,7 +54,7 @@ Align_interface::stretch_after_break (SCM grob) Grob *common = common_refpoint_of_array (elems, me, Y_AXIS); /* force position callbacks */ - for (int i = 0; i < elems.size (); i++) + for (vsize i = 0; i < elems.size (); i++) elems[i]->relative_coordinate (common, Y_AXIS); SCM details = me_spanner->get_bound (LEFT)->get_property ("line-break-system-details"); @@ -68,7 +68,7 @@ Align_interface::stretch_after_break (SCM grob) Direction stacking_dir = robust_scm2dir (me->get_property ("stacking-dir"), DOWN); Real delta = extra_space / elems.size() * stacking_dir; - for (int i = 0; i < elems.size (); i++) + for (vsize i = 0; i < elems.size (); i++) elems[i]->translate_axis (i * delta, Y_AXIS); } @@ -94,9 +94,9 @@ Align_interface::align_to_fixed_distance (Grob *me, Axis a) Interval v; v.set_empty (); - Array translates; + std::vector translates; - for (int j = elems.size (); j--;) + for (vsize j = elems.size (); j--;) { /* This is not very elegant, in that we need special support for @@ -113,17 +113,17 @@ Align_interface::align_to_fixed_distance (Grob *me, Axis a) elems.del (j); } - for (int j = 0; j < elems.size (); j++) + for (vsize j = 0; j < elems.size (); j++) { where_f += stacking_dir * dy; - translates.push (where_f); + translates.push_back (where_f); v.unite (Interval (where_f, where_f)); } /* TODO: support self-alignment-{Y, X} */ - for (int i = 0; i < translates.size (); i++) + for (vsize i = 0; i < translates.size (); i++) elems[i]->translate_axis (translates[i] - v.center (), a); } @@ -159,19 +159,19 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) Interval threshold = robust_scm2interval (me->get_property ("threshold"), Interval (0, Interval::infinity ())); - Array dims; + std::vector dims; Link_array elems; extract_grob_set (me, "elements", all_grobs); - for (int i = 0; i < all_grobs.size (); i++) + for (vsize i = 0; i < all_grobs.size (); i++) { Interval y = all_grobs[i]->extent (me, a); if (!y.is_empty ()) { Grob *e = dynamic_cast (all_grobs[i]); - elems.push (e); - dims.push (y); + elems.push_back (e); + dims.push_back (y); } } @@ -195,8 +195,8 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) : SCM_EOL, extra_space); - Array translates; - for (int j = 0; j < elems.size (); j++) + std::vector translates; + for (vsize j = 0; j < elems.size (); j++) { Real dy = -dims[j][-stacking_dir]; if (j) @@ -211,13 +211,13 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) where += stacking_dir * (dy + extra_space / elems.size ()); total.unite (dims[j] + where); - translates.push (where); + translates.push_back (where); } SCM offsets_handle = scm_assq (ly_symbol2scm ("alignment-offsets"), line_break_details); if (scm_is_pair (offsets_handle)) { - int i = 0; + vsize i = 0; for (SCM s = scm_cdr (offsets_handle); scm_is_pair (s) && i < translates.size (); s = scm_cdr (s), i++) { @@ -232,18 +232,15 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) /* also move the grobs that were empty, to maintain spatial order. */ - Array all_translates; + std::vector all_translates; if (translates.size ()) { - int i = 0; - int j = 0; Real w = translates[0]; - while (j < all_grobs.size ()) + for (vsize i = 0, j = 0; j < all_grobs.size (); j++) { if (i < elems.size () && all_grobs[j] == elems[i]) w = translates[i++]; - all_translates.push (w); - j++; + all_translates.push_back (w); } /* @@ -253,7 +250,7 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) if (scm_is_number (align)) center_offset = total.linear_combination (scm_to_double (align)); - for (int j = 0; j < all_grobs.size (); j++) + for (vsize j = 0; j < all_grobs.size (); j++) all_grobs[j]->translate_axis (all_translates[j] - center_offset, a); } } diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc index 173181254b..d4d95a3e8d 100644 --- a/lily/arpeggio.cc +++ b/lily/arpeggio.cc @@ -26,7 +26,7 @@ Arpeggio::print (SCM smob) Grob *common = me; extract_grob_set (me, "stems", stems); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), @@ -44,7 +44,7 @@ Arpeggio::print (SCM smob) Interval heads; Real my_y = me->relative_coordinate (common, Y_AXIS); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem); @@ -100,7 +100,7 @@ Arpeggio::brew_chord_bracket (SCM smob) Grob *common = me; extract_grob_set (me, "stems", stems); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), @@ -110,7 +110,7 @@ Arpeggio::brew_chord_bracket (SCM smob) Interval heads; Real my_y = me->relative_coordinate (common, Y_AXIS); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem); diff --git a/lily/audio-column.cc b/lily/audio-column.cc index 8957c8a968..c9c880ec07 100644 --- a/lily/audio-column.cc +++ b/lily/audio-column.cc @@ -19,7 +19,7 @@ Audio_column::Audio_column (Moment at_mom) void Audio_column::add_audio_item (Audio_item *l) { - audio_items_.push (l); + audio_items_.push_back (l); l->audio_column_ = this; } diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index 344194d866..75c24d96f3 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -32,7 +32,7 @@ Audio_element_info::origin_contexts (Translator *end) const Link_array r; do { - r.push (t); + r.push_back (t); t = t->get_parent_context (); } while (t && t != end->context ()); diff --git a/lily/audio-staff.cc b/lily/audio-staff.cc index 18df5c9cb6..a715cbc1de 100644 --- a/lily/audio-staff.cc +++ b/lily/audio-staff.cc @@ -15,7 +15,7 @@ void Audio_staff::add_audio_item (Audio_item *l) { - audio_items_.push (l); + audio_items_.push_back (l); } void diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 54949f63b7..f6ed06283b 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -182,7 +182,7 @@ Auto_beam_engraver::create_beam () if (to_boolean (get_property ("skipTypesetting"))) return 0; - for (int i = 0; i < stems_->size (); i++) + for (vsize i = 0; i < stems_->size (); i++) if (Stem::get_beam ((*stems_)[i])) return 0; @@ -193,7 +193,7 @@ Auto_beam_engraver::create_beam () Spanner *beam = new Spanner (beam_settings_, context ()->get_grob_key ("Beam")); - for (int i = 0; i < stems_->size (); i++) + for (vsize i = 0; i < stems_->size (); i++) Beam::add_stem (beam, (*stems_)[i]); announce_grob (beam, (*stems_)[0]->self_scm ()); @@ -387,7 +387,7 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info) grouping_->add_stem (now - beam_start_moment_ + beam_start_location_, durlog - 2); - stems_->push (stem); + stems_->push_back (stem); last_add_mom_ = now; extend_mom_ = max (extend_mom_, now) + m->get_length (); } diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 31d75f0f1c..bc589b25bb 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -22,7 +22,7 @@ protected: virtual void do_quit (); virtual void construct_children (); virtual void process (Moment); - Array pending_pitch (Moment) const; + std::vector pending_pitch (Moment) const; private: SCM split_list_; Direction where_dir_; diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index b20abef88f..b582fa417f 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -56,7 +56,7 @@ Axis_group_engraver::finalize () void Axis_group_engraver::acknowledge_grob (Grob_info i) { - elts_.push (i.grob ()); + elts_.push_back (i.grob ()); } /* @@ -69,7 +69,7 @@ Axis_group_engraver::process_acknowledged () if (!staffline_) return; - for (int i = 0; i < elts_.size (); i++) + for (vsize i = 0; i < elts_.size (); i++) { if (!unsmob_grob (elts_[i]->get_object ("axis-group-parent-Y"))) { diff --git a/lily/axis-group-interface-scheme.cc b/lily/axis-group-interface-scheme.cc index 154521ca4f..f5c7fb1529 100644 --- a/lily/axis-group-interface-scheme.cc +++ b/lily/axis-group-interface-scheme.cc @@ -26,7 +26,7 @@ LY_DEFINE (ly_relative_group_extent, "ly:relative-group-extent", if (!ga) { for (SCM s = elements; scm_is_pair (s); s = scm_cdr (s)) - elts.push (unsmob_grob (scm_car (s))); + elts.push_back (unsmob_grob (scm_car (s))); } Interval ext = Axis_group_interface::relative_group_extent (ga ? ga->array () : elts, diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 11d3a566dc..112dc3d767 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -49,7 +49,7 @@ Axis_group_interface::relative_group_extent (Link_array const &elts, Grob *common, Axis a) { Interval r; - for (int i = 0; i < elts.size (); i++) + for (vsize i = 0; i < elts.size (); i++) { Grob *se = elts[i]; Interval dims = se->extent (common, a); @@ -90,13 +90,13 @@ Axis_group_interface::generic_group_extent (Grob *me, Axis a) void Axis_group_interface::get_children (Grob *me, Link_array *found) { - found->push (me); + found->push_back (me); if (!has_interface (me)) return; extract_grob_set (me, "elements", elements); - for (int i = 0; i < elements.size (); i++) + for (vsize i = 0; i < elements.size (); i++) { Grob *e = elements[i]; Axis_group_interface::get_children (e, found); diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc index 4eb2bab8fd..00ceb61dcd 100644 --- a/lily/beam-concave.cc +++ b/lily/beam-concave.cc @@ -3,18 +3,18 @@ */ #include "pointer-group-interface.hh" -#include "array.hh" +#include "std-vector.hh" #include "stem.hh" #include "beam.hh" #include "staff-symbol-referencer.hh" #include "directional-element-interface.hh" bool -is_concave_single_notes (Array const &positions, Direction beam_dir) +is_concave_single_notes (std::vector const &positions, Direction beam_dir) { Interval covering; covering.add_point (positions[0]); - covering.add_point (positions.top ()); + covering.add_point (positions.back ()); bool above = false; bool below = false; @@ -23,7 +23,7 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) /* notes above and below the interval covered by 1st and last note. */ - for (int i = 1; i < positions.size () - 1; i++) + for (vsize i = 1; i < positions.size () - 1; i++) { above = above || (positions[i] > covering[UP]); below = below || (positions[i] < covering[DOWN]); @@ -34,9 +34,9 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) A note as close or closer to the beam than begin and end, but the note is reached in the opposite direction as the last-first dy */ - int dy = positions.top () - positions[0]; - int closest = max (beam_dir * positions.top (), beam_dir * positions[0]); - for (int i = 2; !concave && i < positions.size () - 1; i++) + int dy = positions.back () - positions[0]; + int closest = max (beam_dir * positions.back (), beam_dir * positions[0]); + for (vsize i = 2; !concave && i < positions.size () - 1; i++) { int inner_dy = positions[i] - positions[i - 1]; if (sign (inner_dy) != sign (dy) @@ -46,7 +46,7 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) } bool all_closer = true; - for (int i = 1; all_closer && i < positions.size () - 1; i++) + for (vsize i = 1; all_closer && i < positions.size () - 1; i++) { all_closer = all_closer && (beam_dir * positions[i] > closest); @@ -57,12 +57,12 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) } Real -calc_positions_concaveness (Array const &positions, Direction beam_dir) +calc_positions_concaveness (std::vector const &positions, Direction beam_dir) { - Real dy = positions.top () - positions[0]; + Real dy = positions.back () - positions[0]; Real slope = dy / Real (positions.size () - 1); Real concaveness = 0.0; - for (int i = 1; i < positions.size () - 1; i++) + for (vsize i = 1; i < positions.size () - 1; i++) { Real line_y = slope * i + positions[0]; @@ -94,7 +94,7 @@ Beam::calc_concaveness (SCM smob) return scm_from_double (0.0); Direction beam_dir = CENTER; - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) { if (Stem::is_invisible (stems[i])) stems.del (i); @@ -108,9 +108,9 @@ Beam::calc_concaveness (SCM smob) if (stems.size () <= 2) return SCM_UNSPECIFIED; - Array close_positions; - Array far_positions; - for (int i = 0; i < stems.size (); i++) + std::vector close_positions; + std::vector far_positions; + for (vsize i = 0; i < stems.size (); i++) { /* For chords, we take the note head that is closest to the beam. @@ -122,8 +122,8 @@ Beam::calc_concaveness (SCM smob) */ Interval posns = Stem::head_positions (stems[i]); - close_positions.push ((int) rint (posns[beam_dir])); - far_positions.push ((int) rint (posns[-beam_dir])); + close_positions.push_back ((int) rint (posns[beam_dir])); + far_positions.push_back ((int) rint (posns[-beam_dir])); } Real concaveness = 0.0; diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index c982c6d812..5b9b2dbaed 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -78,11 +78,11 @@ struct Quant_score */ int -best_quant_score_idx (Array const &qscores) +best_quant_score_idx (std::vector const &qscores) { Real best = 1e6; int best_idx = -1; - for (int i = qscores.size (); i--;) + for (vsize i = qscores.size (); i--;) { if (qscores[i].demerits < best) { @@ -123,8 +123,8 @@ Beam::quanting (SCM smob, SCM posns) Real quants [] = {straddle, sit, inter, hang }; int num_quants = int (sizeof (quants) / sizeof (Real)); - Array quantsl; - Array quantsr; + std::vector quantsl; + std::vector quantsr; /* going to REGION_SIZE == 2, yields another 0.6 second with @@ -141,9 +141,9 @@ Beam::quanting (SCM smob, SCM posns) */ Link_array stems = extract_grob_array (me, "stems"); - Array stem_infos; - Array base_lengths; - Array stem_xposns; + std::vector stem_infos; + std::vector base_lengths; + std::vector stem_xposns; Drul_array dirs_found (0, 0); Grob *common[2]; @@ -163,21 +163,21 @@ Beam::quanting (SCM smob, SCM posns) stem_y != 0.0, when we're cross staff. */ - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; Stem_info si (Stem::get_stem_info (s)); si.scale (1 / ss); - stem_infos.push (si); - dirs_found[stem_infos.top ().dir_] = true; + stem_infos.push_back (si); + dirs_found[stem_infos.back ().dir_] = true; bool f = to_boolean (s->get_property ("french-beaming")) && s != lvs && s != fvs; - base_lengths.push (calc_stem_y (me, s, common, xl, xr, + base_lengths.push_back (calc_stem_y (me, s, common, xl, xr, Interval (0, 0), f) / ss); - stem_xposns.push (s->relative_coordinate (common[X_AXIS], X_AXIS)); + stem_xposns.push_back (s->relative_coordinate (common[X_AXIS], X_AXIS)); } bool xstaff = false; @@ -188,7 +188,7 @@ Beam::quanting (SCM smob, SCM posns) } Direction ldir = Direction (stem_infos[0].dir_); - Direction rdir = Direction (stem_infos.top ().dir_); + Direction rdir = Direction (stem_infos.back ().dir_); bool is_knee = dirs_found[LEFT] && dirs_found[RIGHT]; int region_size = (int) parameters.REGION_SIZE; @@ -205,28 +205,28 @@ Beam::quanting (SCM smob, SCM posns) for (int i = -region_size; i < region_size; i++) for (int j = 0; j < num_quants; j++) { - quantsl.push (i + quants[j] + int (yl)); - quantsr.push (i + quants[j] + int (yr)); + quantsl.push_back (i + quants[j] + int (yl)); + quantsr.push_back (i + quants[j] + int (yr)); } - Array qscores; + std::vector qscores; - for (int l = 0; l < quantsl.size (); l++) - for (int r = 0; r < quantsr.size (); r++) + for (vsize l = 0; l < quantsl.size (); l++) + for (vsize r = 0; r < quantsr.size (); r++) { Quant_score qs; qs.yl = quantsl[l]; qs.yr = quantsr[r]; qs.demerits = 0.0; - qscores.push (qs); + qscores.push_back (qs); } /* This is a longish function, but we don't separate this out into neat modular separate subfunctions, as the subfunctions would be called for many values of YL, YR. By precomputing various parameters outside of the loop, we can save a lot of time. */ - for (int i = qscores.size (); i--;) + for (vsize i = qscores.size (); i--;) { Real d = score_slopes_dy (qscores[i].yl, qscores[i].yr, dy_mus, yr- yl, @@ -242,12 +242,12 @@ Beam::quanting (SCM smob, SCM posns) Real rad = Staff_symbol_referencer::staff_radius (me); Drul_array edge_beam_counts (Stem::beam_multiplicity (stems[0]).length () + 1, - Stem::beam_multiplicity (stems.top ()).length () + 1); + Stem::beam_multiplicity (stems.back ()).length () + 1); Real beam_translation = get_beam_translation (me) / ss; Real reasonable_score = (is_knee) ? 200000 : 100; - for (int i = qscores.size (); i--;) + for (vsize i = qscores.size (); i--;) if (qscores[i].demerits < reasonable_score) { Real d = score_forbidden_quants (qscores[i].yl, qscores[i].yr, @@ -260,7 +260,7 @@ Beam::quanting (SCM smob, SCM posns) #endif } - for (int i = qscores.size (); i--;) + for (vsize i = qscores.size (); i--;) if (qscores[i].demerits < reasonable_score) { Real d = score_stem_lengths (stems, stem_infos, @@ -284,10 +284,8 @@ Beam::quanting (SCM smob, SCM posns) { Drul_array ins = ly_scm2interval (inspect_quants); - int i = 0; - Real mindist = 1e6; - for (; i < qscores.size (); i++) + for (vsize i = 0; i < qscores.size (); i++) { Real d = fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]); if (d < mindist) @@ -330,9 +328,9 @@ Beam::quanting (SCM smob, SCM posns) Real Beam::score_stem_lengths (Link_array const &stems, - Array const &stem_infos, - Array const &base_stem_ys, - Array const &stem_xs, + std::vector const &stem_infos, + std::vector const &base_stem_ys, + std::vector const &stem_xs, Real xl, Real xr, bool knee, Real yl, Real yr, @@ -343,7 +341,7 @@ Beam::score_stem_lengths (Link_array const &stems, Drul_array score (0, 0); Drul_array count (0, 0); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; if (Stem::is_invisible (s)) diff --git a/lily/beam.cc b/lily/beam.cc index 5861dba321..712c4d5c04 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -91,7 +91,7 @@ Beam::get_beam_count (Grob *me) int m = 0; extract_grob_set (me, "stems", stems); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; m = max (m, (Stem::beam_multiplicity (stem).length () + 1)); @@ -218,7 +218,7 @@ Beam::calc_beaming (SCM smob) SCM last_beaming = scm_cons (SCM_EOL, scm_list_1 (scm_from_int (0))); Direction last_dir = CENTER; - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *this_stem = stems[i]; SCM this_beaming = this_stem->get_property ("beaming"); @@ -300,7 +300,7 @@ Beam::print (SCM grob) else { x0 = stems[0]->relative_coordinate (xcommon, X_AXIS); - dx = stems.top ()->relative_coordinate (xcommon, X_AXIS) - x0; + dx = stems.back ()->relative_coordinate (xcommon, X_AXIS) - x0; } SCM posns = me->get_property ("quantized-positions"); @@ -330,7 +330,7 @@ Beam::print (SCM grob) Stencil the_beam; Real lt = me->layout ()->get_dimension (ly_symbol2scm ("linethickness")); - for (int i = 0; i <= stems.size (); i++) + for (vsize i = 0; i <= stems.size (); i++) { Grob *stem = (i < stems.size ()) ? stems[i] : 0; @@ -346,25 +346,25 @@ Beam::print (SCM grob) SCM left = (i > 0) ? scm_cdr (last_beaming) : SCM_EOL; SCM right = stem ? scm_car (this_beaming) : SCM_EOL; - Array full_beams; - Array lfliebertjes; - Array rfliebertjes; + std::vector full_beams; + std::vector lfliebertjes; + std::vector rfliebertjes; for (SCM s = left; scm_is_pair (s); s = scm_cdr (s)) { int b = scm_to_int (scm_car (s)); if (scm_c_memq (scm_car (s), right) != SCM_BOOL_F) - full_beams.push (b); + full_beams.push_back (b); else - lfliebertjes.push (b); + lfliebertjes.push_back (b); } for (SCM s = right; scm_is_pair (s); s = scm_cdr (s)) { int b = scm_to_int (scm_car (s)); if (scm_c_memq (scm_car (s), left) == SCM_BOOL_F) - rfliebertjes.push (b); + rfliebertjes.push_back (b); } Drul_array break_overshoot @@ -401,7 +401,7 @@ Beam::print (SCM grob) } int k = 0; - for (int j = full_beams.size (); j--;) + for (vsize j = full_beams.size (); j--;) { Stencil b (whole); @@ -460,7 +460,7 @@ Beam::print (SCM grob) Stencil rhalf = Lookup::beam (slope, rw, thick, blot); Stencil lhalf = Lookup::beam (slope, lw, thick, blot); - for (int j = lfliebertjes.size (); j--;) + for (vsize j = lfliebertjes.size (); j--;) { Stencil b (lhalf); b.translate_axis (last_xposn - x0 - last_stem_width /2, @@ -470,7 +470,7 @@ Beam::print (SCM grob) Y_AXIS); the_beam.add_stencil (b); } - for (int j = rfliebertjes.size (); j--;) + for (vsize j = rfliebertjes.size (); j--;) { Stencil b (rhalf); b.translate_axis (xposn - x0 - rw + stem_width / 2, X_AXIS); @@ -526,7 +526,7 @@ Beam::get_default_dir (Grob *me) extract_grob_set (me, "stems", stems); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; Direction stem_dir = CENTER; @@ -570,7 +570,7 @@ Beam::set_stem_directions (Grob *me, Direction d) { extract_grob_set (me, "stems", stems); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; @@ -608,8 +608,8 @@ Beam::consider_auto_knees (Grob *me) Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); Real staff_space = Staff_symbol_referencer::staff_space (me); - Array head_extents_array; - for (int i = 0; i < stems.size (); i++) + std::vector head_extents_array; + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; if (Stem::is_invisible (stem)) @@ -635,7 +635,7 @@ Beam::consider_auto_knees (Grob *me) head_extents[-stemdir] = -stemdir * infinity_f; } } - head_extents_array.push (head_extents); + head_extents_array.push_back (head_extents); gaps.remove_interval (head_extents); } @@ -643,7 +643,7 @@ Beam::consider_auto_knees (Grob *me) Interval max_gap; Real max_gap_len = 0.0; - for (int i = gaps.allowed_regions_.size () -1; i >= 0; i--) + for (vsize i = gaps.allowed_regions_.size () -1; i != VPOS ;i--) { Interval gap = gaps.allowed_regions_[i]; @@ -670,7 +670,7 @@ Beam::consider_auto_knees (Grob *me) if (max_gap_len > threshold) { int j = 0; - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *stem = stems[i]; if (Stem::is_invisible (stem)) @@ -779,7 +779,7 @@ Beam::calc_least_squares_positions (SCM smob, SCM posns) if (count < 1) return ly_interval2scm (pos); - Array x_posns; + std::vector x_posns; extract_grob_set (me, "stems", stems); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS); @@ -795,12 +795,12 @@ Beam::calc_least_squares_positions (SCM smob, SCM posns) + lvs->relative_coordinate (commony, Y_AXIS) - my_y); Real x0 = first_visible_stem (me)->relative_coordinate (commonx, X_AXIS); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; Real x = s->relative_coordinate (commonx, X_AXIS) - x0; - x_posns.push (x); + x_posns.push_back (x); } Real dx = last_visible_stem (me)->relative_coordinate (commonx, X_AXIS) - x0; @@ -839,13 +839,13 @@ Beam::calc_least_squares_positions (SCM smob, SCM posns) } else { - Array ideals; - for (int i = 0; i < stems.size (); i++) + std::vector ideals; + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; if (Stem::is_invisible (s)) continue; - ideals.push (Offset (x_posns[i], + ideals.push_back (Offset (x_posns[i], Stem::get_stem_info (s).ideal_y_ + s->relative_coordinate (commony, Y_AXIS) - my_y)); @@ -885,7 +885,7 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) /* Code dup. */ - Array x_posns; + std::vector x_posns; extract_grob_set (me, "stems", stems); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS); @@ -896,12 +896,12 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) return posns; Real x0 = fvs->relative_coordinate (commonx, X_AXIS); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; Real x = s->relative_coordinate (commonx, X_AXIS) - x0; - x_posns.push (x); + x_posns.push_back (x); } Grob *lvs = last_visible_stem (me); @@ -925,7 +925,7 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) */ Interval feasible_left_point; feasible_left_point.set_full (); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; if (Stem::is_invisible (s)) @@ -1127,7 +1127,7 @@ Beam::set_stem_lengths (SCM smob) Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; Real xr = lvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; if (Stem::is_invisible (s)) @@ -1157,7 +1157,7 @@ Beam::set_beaming (Grob *me, Beaming_info_list const *beaming) extract_grob_set (me, "stems", stems); Direction d = LEFT; - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { /* Don't overwrite user settings. @@ -1188,7 +1188,7 @@ Beam::forced_stem_count (Grob *me) extract_grob_set (me, "stems", stems); int f = 0; - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; @@ -1212,7 +1212,7 @@ Beam::visible_stem_count (Grob *me) { extract_grob_set (me, "stems", stems); int c = 0; - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) { if (!Stem::is_invisible (stems[i])) c++; @@ -1225,7 +1225,7 @@ Beam::first_visible_stem (Grob *me) { extract_grob_set (me, "stems", stems); - for (int i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) { if (!Stem::is_invisible (stems[i])) return stems[i]; @@ -1238,7 +1238,7 @@ Beam::last_visible_stem (Grob *me) { extract_grob_set (me, "stems", stems); - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) { if (!Stem::is_invisible (stems[i])) return stems[i]; @@ -1353,7 +1353,7 @@ Beam::is_knee (Grob *me) bool knee = false; int d = 0; extract_grob_set (me, "stems", stems); - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) { Direction dir = get_grob_direction (stems[i]); if (d && d != dir) @@ -1375,7 +1375,7 @@ Beam::get_direction_beam_count (Grob *me, Direction d) extract_grob_set (me, "stems", stems); int bc = 0; - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) { /* Should we take invisible stems into account? diff --git a/lily/beaming-info.cc b/lily/beaming-info.cc index 10f3681a56..7a5428c1ba 100644 --- a/lily/beaming-info.cc +++ b/lily/beaming-info.cc @@ -31,7 +31,7 @@ Beaming_info_list::best_splitpoint_index (Moment &beat_length, bool subdivide) c int minidx = -1; Moment beat_pos; - for (int i = 1; i < infos_.size (); i++) + for (vsize i = 1; i < infos_.size (); i++) { beat_pos = infos_[i].start_mom_ / beat_length; int den = beat_pos.den (); @@ -98,7 +98,7 @@ Beaming_info_list::beamify (Moment &beat_length, bool subdivide) void Beaming_info_list::add_stem (Moment m, int b) { - infos_.push (Beaming_info (m, b)); + infos_.push_back (Beaming_info (m, b)); } void @@ -107,6 +107,6 @@ Beaming_info_list::clip_edges () if (infos_.size ()) { infos_[0].beams_i_drul_[LEFT] = 0; - infos_.top().beams_i_drul_[RIGHT] = 0; + infos_.back ().beams_i_drul_[RIGHT] = 0; } } diff --git a/lily/bezier.cc b/lily/bezier.cc index 4752bc67f9..193018f210 100644 --- a/lily/bezier.cc +++ b/lily/bezier.cc @@ -30,9 +30,9 @@ binomial_coefficient (Real over, int under) } void -scale (Array *array, Real x, Real y) +scale (std::vector *array, Real x, Real y) { - for (int i = 0; i < array->size (); i++) + for (vsize i = 0; i < array->size (); i++) { (*array)[i][X_AXIS] = x * (*array)[i][X_AXIS]; (*array)[i][Y_AXIS] = y * (*array)[i][Y_AXIS]; @@ -40,17 +40,17 @@ scale (Array *array, Real x, Real y) } void -rotate (Array *array, Real phi) +rotate (std::vector *array, Real phi) { Offset rot (complex_exp (Offset (0, phi))); - for (int i = 0; i < array->size (); i++) + for (vsize i = 0; i < array->size (); i++) (*array)[i] = complex_multiply (rot, (*array)[i]); } void -translate (Array *array, Offset o) +translate (std::vector *array, Offset o) { - for (int i = 0; i < array->size (); i++) + for (vsize i = 0; i < array->size (); i++) (*array)[i] += o; } @@ -67,7 +67,7 @@ Real Bezier::get_other_coordinate (Axis a, Real x) const { Axis other = Axis ((a +1) % NO_AXES); - Array ts = solve_point (a, x); + std::vector ts = solve_point (a, x); if (ts.size () == 0) { @@ -169,10 +169,10 @@ Bezier::polynomial (Axis a) const /** Remove all numbers outside [0, 1] from SOL */ -Array -filter_solutions (Array sol) +std::vector +filter_solutions (std::vector sol) { - for (int i = sol.size (); i--;) + for (vsize i = sol.size (); i--;) if (sol[i] < 0 || sol[i] > 1) sol.del (i); return sol; @@ -181,7 +181,7 @@ filter_solutions (Array sol) /** find t such that derivative is proportional to DERIV */ -Array +std::vector Bezier::solve_derivative (Offset deriv) const { Polynomial xp = polynomial (X_AXIS); @@ -197,13 +197,13 @@ Bezier::solve_derivative (Offset deriv) const /* Find t such that curve_point (t)[AX] == COORDINATE */ -Array +std::vector Bezier::solve_point (Axis ax, Real coordinate) const { Polynomial p (polynomial (ax)); p.coefs_[0] -= coordinate; - Array sol (p.solve ()); + std::vector sol (p.solve ()); return filter_solutions (sol); } @@ -217,10 +217,10 @@ Bezier::extent (Axis a) const Offset d; d[Axis (o)] = 1.0; Interval iv; - Array sols (solve_derivative (d)); - sols.push (1.0); - sols.push (0.0); - for (int i = sols.size (); i--;) + std::vector sols (solve_derivative (d)); + sols.push_back (1.0); + sols.push_back (0.0); + for (vsize i = sols.size (); i--;) { Offset o (curve_point (sols[i])); iv.unite (Interval (o[a], o[a])); diff --git a/lily/box.cc b/lily/box.cc index c2db1f2ac6..5201ca125c 100644 --- a/lily/box.cc +++ b/lily/box.cc @@ -9,7 +9,7 @@ #include "ly-smobs.icc" #include "box.hh" -#include "array.hh" +#include "std-vector.hh" void Box::translate (Offset o) diff --git a/lily/break-algorithm.cc b/lily/break-algorithm.cc index 083aca8cbe..abe15eea2f 100644 --- a/lily/break-algorithm.cc +++ b/lily/break-algorithm.cc @@ -15,15 +15,15 @@ #include "cpu-timer.hh" #include "simple-spacer.hh" -Array +std::vector Break_algorithm::find_break_indices () const { Link_array all = pscore_->root_system ()->columns (); - Array retval; + std::vector retval; - for (int i = 0; i < all.size (); i++) + for (vsize i = 0; i < all.size (); i++) if (Item::is_breakable (all[i])) - retval.push (i); + retval.push_back (i); if (linewidth_ <= 0) while (retval.size () > 2) @@ -38,9 +38,9 @@ Break_algorithm::find_breaks () const Link_array all = pscore_->root_system ()->columns (); Link_array retval; - for (int i = 0; i < all.size (); i++) + for (vsize i = 0; i < all.size (); i++) if (Item::is_breakable (all[i])) - retval.push (all[i]); + retval.push_back (all[i]); if (linewidth_ <= 0) while (retval.size () > 2) @@ -88,10 +88,10 @@ Break_algorithm::set_pscore (Paper_score *s) linewidth_ = s->layout ()->get_dimension (ly_symbol2scm ("linewidth")); } -Array +std::vector Break_algorithm::solve () const { - Array h= do_solve (); + std::vector h= do_solve (); return h; } diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index 233bb33e45..3aff11a20e 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -68,12 +68,12 @@ Break_align_interface::ordered_elements (Grob *grob) { SCM sym = scm_car (order); - for (int i = writable_elts.size (); i--;) + for (vsize i = writable_elts.size (); i--;) { Grob *g = writable_elts[i]; if (g && sym == g->get_property ("break-align-symbol")) { - new_elts.push (g); + new_elts.push_back (g); writable_elts.del (i); } } @@ -96,31 +96,31 @@ Break_align_interface::calc_positioning_done (SCM smob) Item *me = dynamic_cast (grob); Link_array elems = ordered_elements (me); - Array extents; + std::vector extents; int last_nonempty = -1; - for (int i = 0; i < elems.size (); i++) + for (vsize i = 0; i < elems.size (); i++) { Interval y = elems[i]->extent (elems[i], X_AXIS); - extents.push (y); + extents.push_back (y); if (!y.is_empty ()) last_nonempty = i; } - int idx = 0; + vsize idx = 0; while (idx < extents.size () && extents[idx].is_empty ()) idx++; - Array offsets; - offsets.set_size (elems.size ()); - for (int i = 0; i < offsets.size ();i++) + std::vector offsets; + offsets.resize (elems.size ()); + for (vsize i = 0; i < offsets.size ();i++) offsets[i] = 0.0; Real extra_right_space = 0.0; - int edge_idx = -1; + vsize edge_idx = VPOS; while (idx < elems.size ()) { - int next_idx = idx + 1; + vsize next_idx = idx + 1; while (next_idx < elems.size () && extents[next_idx].is_empty ()) next_idx++; @@ -138,11 +138,11 @@ Break_align_interface::calc_positioning_done (SCM smob) */ extract_grob_set (l, "elements", elts); - for (int i = elts.size (); i--;) + for (vsize i = elts.size (); i--;) { Grob *elt = elts[i]; - if (edge_idx < 0 + if (edge_idx == VPOS && elt->get_property ("break-align-symbol") == ly_symbol2scm ("left-edge")) edge_idx = idx; @@ -165,7 +165,7 @@ Break_align_interface::calc_positioning_done (SCM smob) if (r) { extract_grob_set (r, "elements", elts); - for (int i = elts.size (); + for (vsize i = elts.size (); !scm_is_symbol (rsym) && i--;) { Grob *elt = elts[i]; @@ -226,7 +226,7 @@ Break_align_interface::calc_positioning_done (SCM smob) Interval total_extent; Real alignment_off = 0.0; - for (int i = 0; i < offsets.size (); i++) + for (vsize i = 0; i < offsets.size (); i++) { here += offsets[i]; if (i == edge_idx) @@ -239,11 +239,11 @@ Break_align_interface::calc_positioning_done (SCM smob) if (me->break_status_dir () == LEFT) alignment_off = -total_extent[RIGHT] - extra_right_space; - else if (edge_idx < 0) + else if (edge_idx == VPOS) alignment_off = -total_extent[LEFT]; here = alignment_off; - for (int i = 0; i < offsets.size (); i++) + for (vsize i = 0; i < offsets.size (); i++) { here += offsets[i]; elems[i]->translate_axis (here, X_AXIS); diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index 764186ee3f..d14092876f 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -148,10 +148,10 @@ substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr) ? & temporary_substition_array : &new_arr->array_reference ()); - new_grobs->set_size (old_grobs.size ()); + new_grobs->resize (old_grobs.size ()); Grob **array = (Grob **) new_grobs->accesses (); Grob **ptr = array; - for (int i = 0; i < old_grobs.size (); i++) + for (vsize i = 0; i < old_grobs.size (); i++) { Grob *orig = old_grobs[i]; Grob *new_grob = substitute_grob (orig); @@ -159,7 +159,7 @@ substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr) *ptr++ = new_grob; } - new_grobs->set_size (ptr - array); + new_grobs->resize (ptr - array); if (new_arr == grob_arr) new_arr->set_array (*new_grobs); } @@ -225,7 +225,7 @@ spanner_system_range (Spanner *sp) { if (sp->broken_intos_.size ()) rv = Slice (sp->broken_intos_[0]->get_system ()->get_rank (), - sp->broken_intos_.top ()->get_system ()->get_rank ()); + sp->broken_intos_.back ()->get_system ()->get_rank ()); } return rv; } @@ -337,7 +337,7 @@ Spanner::fast_substitute_grob_array (SCM sym, int spanner_index = len; int item_index = 0; - for (int i = 0; i < grob_array->size (); i++) + for (vsize i = 0; i < grob_array->size (); i++) { Grob *g = grob_array->grob (i); @@ -356,15 +356,15 @@ Spanner::fast_substitute_grob_array (SCM sym, qsort (vec, item_index, sizeof (Substitution_entry), &Substitution_entry::item_compare); - Array item_indices; - Array spanner_indices; + std::vector item_indices; + std::vector spanner_indices; for (int i = 0; i <= system_range.length (); i++) { - item_indices.push (Slice (len, 0)); - spanner_indices.push (Slice (len, 0)); + item_indices.push_back (Slice (len, 0)); + spanner_indices.push_back (Slice (len, 0)); } - Array *arrs[] + std::vector *arrs[] = { &item_indices, &spanner_indices }; @@ -380,14 +380,14 @@ Spanner::fast_substitute_grob_array (SCM sym, is a waste of time -- the staff-spanners screw up the ordering, since they go across the entire score. */ - for (int i = spanner_indices.size (); i--;) + for (vsize i = spanner_indices.size (); i--;) spanner_indices[i] = Slice (spanner_index, len - 1); assert (item_index <= spanner_index); - assert ((broken_intos_.size () == system_range.length () + 1) - || (broken_intos_.is_empty () && system_range.length () == 0)); - for (int i = 0; i < broken_intos_.size (); i++) + assert ((broken_intos_.size () == (vsize)system_range.length () + 1) + || (broken_intos_.empty () && system_range.length () == 0)); + for (vsize i = 0; i < broken_intos_.size (); i++) { Grob *sc = broken_intos_[i]; System *l = sc->get_system (); @@ -488,7 +488,7 @@ Spanner::substitute_one_mutable_property (SCM sym, fast_done = s->fast_substitute_grob_array (sym, grob_array); if (!fast_done) - for (int i = 0; i < s->broken_intos_.size (); i++) + for (vsize i = 0; i < s->broken_intos_.size (); i++) { Grob *sc = s->broken_intos_[i]; System *l = sc->get_system (); diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index b20985f95e..e079e982c0 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -56,7 +56,7 @@ Chord_name_engraver::Chord_name_engraver () void Chord_name_engraver::add_note (Music *n) { - notes_.push (n); + notes_.push_back (n); } void @@ -70,7 +70,7 @@ Chord_name_engraver::process_music () SCM pitches = SCM_EOL; Music *inversion_event = 0; - for (int i = 0; i < notes_.size (); i++) + for (vsize i = 0; i < notes_.size (); i++) { Music *n = notes_[i]; SCM p = n->get_property ("pitch"); diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index c5eecd6b9c..8291736944 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -60,7 +60,7 @@ Cluster_spanner_engraver::try_music (Music *m) { if (m->is_mus_type ("cluster-note-event")) { - cluster_notes_.push (m); + cluster_notes_.push_back (m); return true; } else if (m->is_mus_type ("busy-playing-event")) @@ -80,7 +80,7 @@ Cluster_spanner_engraver::process_music () int pmax = INT_MIN; int pmin = INT_MAX; - for (int i = 0; i < cluster_notes_.size (); i++) + for (vsize i = 0; i < cluster_notes_.size (); i++) { Pitch *pit = unsmob_pitch (cluster_notes_[i]->get_property ("pitch")); diff --git a/lily/cluster.cc b/lily/cluster.cc index a81df96cc4..02fd9e3b40 100644 --- a/lily/cluster.cc +++ b/lily/cluster.cc @@ -27,7 +27,7 @@ using namespace std; TODO: Add support for cubic spline segments. */ Stencil -brew_cluster_piece (Grob *me, Array bottom_points, Array top_points) +brew_cluster_piece (Grob *me, std::vector bottom_points, std::vector top_points) { Real blotdiameter = Staff_symbol_referencer::staff_space (me) / 2; @@ -50,7 +50,7 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array top_poi } Stencil out; - Array points; + std::vector points; points.clear (); int size = bottom_points.size (); if (shape == "leftsided-stairs") @@ -100,14 +100,14 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array top_poi } else if (shape == "ramp") { - points.push (bottom_points[0] - vpadding + hpadding); + points.push_back (bottom_points[0] - vpadding + hpadding); for (int i = 1; i < size - 1; i++) - points.push (bottom_points[i] - vpadding); - points.push (bottom_points[size - 1] - vpadding - hpadding); - points.push (top_points[size - 1] + vpadding - hpadding); + points.push_back (bottom_points[i] - vpadding); + points.push_back (bottom_points[size - 1] - vpadding - hpadding); + points.push_back (top_points[size - 1] + vpadding - hpadding); for (int i = size - 2; i > 0; i--) - points.push (top_points[i] + vpadding); - points.push (top_points[0] + vpadding + hpadding); + points.push_back (top_points[i] + vpadding); + points.push_back (top_points[0] + vpadding + hpadding); out.add_stencil (Lookup::round_filled_polygon (points, blotdiameter)); } else @@ -134,7 +134,7 @@ Cluster::print (SCM smob) Grob *commonx = left_bound->common_refpoint (right_bound, X_AXIS); Link_array const &cols = extract_grob_array (me, "columns"); - if (cols.is_empty ()) + if (cols.empty ()) { me->warning (_ ("junking empty cluster")); me->suicide (); @@ -144,8 +144,8 @@ Cluster::print (SCM smob) commonx = common_refpoint_of_array (cols, commonx, X_AXIS); Grob *commony = common_refpoint_of_array (cols, me, Y_AXIS); - Array bottom_points; - Array top_points; + std::vector bottom_points; + std::vector top_points; Real left_coord = left_bound->relative_coordinate (commonx, X_AXIS); @@ -154,15 +154,15 @@ Cluster::print (SCM smob) line with the center of the note heads? */ - for (int i = 0; i < cols.size (); i++) + for (vsize i = 0; i < cols.size (); i++) { Grob *col = cols[i]; Interval yext = col->extent (commony, Y_AXIS); Real x = col->relative_coordinate (commonx, X_AXIS) - left_coord; - bottom_points.push (Offset (x, yext[DOWN])); - top_points.push (Offset (x, yext[UP])); + bottom_points.push_back (Offset (x, yext[DOWN])); + top_points.push_back (Offset (x, yext[UP])); } /* diff --git a/lily/coherent-ligature-engraver.cc b/lily/coherent-ligature-engraver.cc index 8ab2e16f2d..113c3b2666 100644 --- a/lily/coherent-ligature-engraver.cc +++ b/lily/coherent-ligature-engraver.cc @@ -35,7 +35,7 @@ * - collapse superflous space after each ligature (TODO). * * Concrete subclasses must implement function build_ligature (Spanner - * *, Array). This function is responsible for actually + * *, std::vector). This function is responsible for actually * building the ligature by transforming the array of noteheads. * * Currently, there are two subclasses: Gregorian_ligature_engraver @@ -125,7 +125,7 @@ Coherent_ligature_engraver::get_set_column (Item *item, Paper_column *column) extract_item_set (parent, "elements", elements); - for (int i = elements.size (); i--;) + for (vsize i = elements.size (); i--;) { Item *sibling = elements[i]; if ((sibling) @@ -159,18 +159,18 @@ Coherent_ligature_engraver::get_set_column (Item *item, Paper_column *column) * occurs within the broken ligatures any more. */ void -Coherent_ligature_engraver::collect_accidentals (Spanner *, Array) +Coherent_ligature_engraver::collect_accidentals (Spanner *, std::vector) { /* TODO */ } void -compute_delta_pitches (Array primitives) +compute_delta_pitches (std::vector primitives) { int prev_pitch = 0; int delta_pitch = 0; Item *prev_primitive = 0, *primitive = 0; - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { primitive = dynamic_cast (primitives[i].grob ()); Music *music_cause = primitives[i].music_cause (); @@ -190,7 +190,7 @@ compute_delta_pitches (Array primitives) void Coherent_ligature_engraver::typeset_ligature (Spanner *ligature, - Array primitives) + std::vector primitives) { // compute some commonly needed context info stored as grob // properties diff --git a/lily/collision-engraver.cc b/lily/collision-engraver.cc index 637d6d9643..285dd90820 100644 --- a/lily/collision-engraver.cc +++ b/lily/collision-engraver.cc @@ -32,7 +32,7 @@ Collision_engraver::process_acknowledged () if (!col_) col_ = make_item ("NoteCollision", SCM_EOL); - for (int i = 0; i < note_columns_.size (); i++) + for (vsize i = 0; i < note_columns_.size (); i++) Note_collision_interface::add_column (col_, note_columns_[i]); } @@ -45,7 +45,7 @@ Collision_engraver::acknowledge_note_column (Grob_info i) if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS)) return; - note_columns_.push (i.grob ()); + note_columns_.push_back (i.grob ()); } } diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 3ab3a3f6e2..7bdf2e3ba5 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -81,7 +81,7 @@ Completion_heads_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { - note_events_.push (m); + note_events_.push_back (m); is_first_ = true; Moment musiclen = m->get_length (); @@ -192,15 +192,14 @@ Completion_heads_engraver::process_music () if (orig && note_dur.get_length () != orig->get_length ()) { if (!scratch_note_events_.size ()) - for (int i = 0; i < note_events_.size (); i++) + for (vsize i = 0; i < note_events_.size (); i++) { Music *m = note_events_[i]->clone (); - scratch_note_events_.push (m); + scratch_note_events_.push_back (m); } } - for (int i = 0; - left_to_do_ && i < note_events_.size (); i++) + for (vsize i = 0; left_to_do_ && i < note_events_.size (); i++) { Music *event = note_events_[i]; if (scratch_note_events_.size ()) @@ -229,7 +228,7 @@ Completion_heads_engraver::process_music () d->set_property ("dot-count", scm_from_int (dots)); d->set_parent (note, Y_AXIS); - dots_.push (d); + dots_.push_back (d); } Pitch *pit = unsmob_pitch (event->get_property ("pitch")); @@ -240,18 +239,18 @@ Completion_heads_engraver::process_music () pos += scm_to_int (c0); note->set_property ("staff-position", scm_from_int (pos)); - notes_.push (note); + notes_.push_back (note); } if (prev_notes_.size () == notes_.size ()) { - for (int i = 0; i < notes_.size (); i++) + for (vsize i = 0; i < notes_.size (); i++) { Grob *p = make_spanner ("Tie", SCM_EOL); Tie::set_head (p, LEFT, prev_notes_[i]); Tie::set_head (p, RIGHT, notes_[i]); - ties_.push (p); + ties_.push_back (p); } } @@ -276,7 +275,7 @@ Completion_heads_engraver::stop_translation_timestep () dots_.clear (); - for (int i = scratch_note_events_.size (); i--;) + for (vsize i = scratch_note_events_.size (); i--;) scratch_note_events_[i]->unprotect (); scratch_note_events_.clear (); diff --git a/lily/context-def.cc b/lily/context-def.cc index ee4220469a..545afabb1a 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -203,22 +203,22 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const 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 (t); + accepteds.push_back (t); Link_array best_result; - for (int i = 0; i < accepteds.size (); i++) + for (vsize i = 0; i < accepteds.size (); i++) { /* do not check aliases, because \context Staff should not create RhythmicStaff. */ if (ly_is_equal (accepteds[i]->get_context_name (), type_sym)) { - best_result.push (accepteds[i]); + best_result.push_back (accepteds[i]); return best_result; } } - int best_depth = INT_MAX; - for (int i = 0; i < accepteds.size (); i++) + vsize best_depth = UINT_MAX; + for (vsize i = 0; i < accepteds.size (); i++) { Context_def *g = accepteds[i]; diff --git a/lily/context.cc b/lily/context.cc index cc4536279e..405dc4b5d4 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -132,7 +132,7 @@ Context::create_unique_context (SCM n, SCM operations) Context *current = this; // start at 1. The first one (index 0) will be us. - for (int i = 0; i < path.size (); i++) + for (vsize i = 0; i < path.size (); i++) { SCM ops = (i == path.size () -1) ? operations : SCM_EOL; @@ -190,7 +190,7 @@ Context::find_create_context (SCM n, std::string id, SCM operations) Context *current = this; // start at 1. The first one (index 0) will be us. - for (int i = 0; i < path.size (); i++) + for (vsize i = 0; i < path.size (); i++) { SCM ops = (i == path.size () -1) ? operations : SCM_EOL; diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index eb292f86e5..53f24a6f7c 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -38,7 +38,7 @@ private: Item *create_custos (); bool custos_permitted_; Link_array custodes_; - Array pitches_; + std::vector pitches_; }; Custos_engraver::Custos_engraver () @@ -85,7 +85,7 @@ Custos_engraver::acknowledge_note_head (Grob_info info) don't look at the staff-position, since we can't be sure whether Clef_engraver already applied a vertical shift. */ - pitches_.push (*unsmob_pitch (m->get_property ("pitch"))); + pitches_.push_back (*unsmob_pitch (m->get_property ("pitch"))); } } @@ -97,7 +97,7 @@ Custos_engraver::process_acknowledged () if (custos_permitted_) { - for (int i = pitches_.size (); i--;) + for (vsize i = pitches_.size (); i--;) { Item *c = create_custos (); @@ -119,7 +119,7 @@ Custos_engraver::create_custos () { Item *custos = make_item ("Custos", SCM_EOL); - custodes_.push (custos); + custodes_.push_back (custos); return custos; } @@ -127,7 +127,7 @@ Custos_engraver::create_custos () void Custos_engraver::finalize () { - for (int i = custodes_.size (); i--;) + for (vsize i = custodes_.size (); i--;) custodes_[i]->suicide (); custodes_.clear (); } diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 630e154d95..78dbcabb4c 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -212,7 +212,7 @@ Dot_column::calc_positioning_done (SCM smob) dots when merging. */ Grob *c = 0; - for (int i = dots.size (); i--;) + for (vsize i = dots.size (); i--;) { Grob *n = dots[i]->get_parent (Y_AXIS); if (c) @@ -220,7 +220,7 @@ Dot_column::calc_positioning_done (SCM smob) else c = n; } - for (int i = dots.size (); i--;) + for (vsize i = dots.size (); i--;) { Grob *n = dots[i]->get_parent (Y_AXIS); n->relative_coordinate (c, X_AXIS); @@ -228,12 +228,12 @@ Dot_column::calc_positioning_done (SCM smob) } dots.sort (compare_position); - for (int i = dots.size (); i--;) + for (vsize i = dots.size (); i--;) if (!dots[i]->is_live ()) dots.del (i); Dot_configuration cfg; - for (int i = 0;i < dots.size (); i++) + for (vsize i = 0;i < dots.size (); i++) { Dot_position dp; dp.dot_ = dots[i]; diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 1b95c519ad..4494e2c729 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -43,7 +43,7 @@ Drum_notes_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { - events_.push (m); + events_.push_back (m); return true; } else if (m->is_mus_type ("busy-playing-event")) @@ -56,7 +56,7 @@ void Drum_notes_engraver::process_music () { SCM tab = 0; - for (int i = 0; i < events_.size (); i++) + for (vsize i = 0; i < events_.size (); i++) { if (!tab) tab = get_property ("drumStyleTable"); @@ -79,7 +79,7 @@ Drum_notes_engraver::process_music () d->set_parent (note, Y_AXIS); - dots_.push (d); + dots_.push_back (d); } SCM drum_type = ev->get_property ("drum-type"); @@ -108,18 +108,18 @@ Drum_notes_engraver::process_music () p->set_parent (note, Y_AXIS); Side_position_interface::add_support (p, note); - scripts_.push (p); + scripts_.push_back (p); } } - notes_.push (note); + notes_.push_back (note); } } void Drum_notes_engraver::acknowledge_stem (Grob_info inf) { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i]; @@ -133,7 +133,7 @@ Drum_notes_engraver::acknowledge_stem (Grob_info inf) void Drum_notes_engraver::acknowledge_note_column (Grob_info inf) { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i]; diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index e0a0606df3..dd83e6699f 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -53,7 +53,7 @@ Drum_note_performer::process_music () Audio_note *p = new Audio_note (*pit, n->get_length (), 0); Audio_element_info info (p, n); announce_element (info); - notes_.push (p); + notes_.push_back (p); } } @@ -66,7 +66,7 @@ Drum_note_performer::stop_translation_timestep () // why don't grace notes show up here? // --> grace notes effectively do not get delayed Moment now = now_mom (); - for (int i = 0; i < notes_.size (); i++) + for (vsize i = 0; i < notes_.size (); i++) play_element (notes_[i]); notes_.clear (); note_evs_.clear (); @@ -77,7 +77,7 @@ Drum_note_performer::try_music (Music *ev) { if (ev->is_mus_type ("note-event")) { - note_evs_.push (ev); + note_evs_.push_back (ev); return true; } else if (ev->is_mus_type ("busy-playing-event")) diff --git a/lily/enclosing-bracket.cc b/lily/enclosing-bracket.cc index 2e10d71fdf..c1e6f57cf5 100644 --- a/lily/enclosing-bracket.cc +++ b/lily/enclosing-bracket.cc @@ -44,7 +44,7 @@ Enclosing_bracket::print (SCM grob) { Grob *me = unsmob_grob (grob); extract_grob_set (me, "elements", elements); - if (elements.is_empty ()) + if (elements.empty ()) { me->suicide (); return SCM_EOL; diff --git a/lily/engraver-group.cc b/lily/engraver-group.cc index 36b2838103..5742288d69 100644 --- a/lily/engraver-group.cc +++ b/lily/engraver-group.cc @@ -17,7 +17,7 @@ void Engraver_group::announce_grob (Grob_info info) { - announce_infos_.push (info); + announce_infos_.push_back (info); Engraver_group *dad_eng = context_->get_parent_context () @@ -36,7 +36,7 @@ Engraver_group::acknowledge_grobs () SCM name_sym = ly_symbol2scm ("name"); SCM meta_sym = ly_symbol2scm ("meta"); - for (int j = 0; j < announce_infos_.size (); j++) + for (vsize j = 0; j < announce_infos_.size (); j++) { Grob_info info = announce_infos_[j]; diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc index a0799a7ff0..d3b2e90972 100644 --- a/lily/extender-engraver.cc +++ b/lily/extender-engraver.cc @@ -116,7 +116,7 @@ completize_extender (Spanner *sp) { extract_item_set (sp, "heads", heads); if (heads.size ()) - sp->set_bound (RIGHT, heads.top ()); + sp->set_bound (RIGHT, heads.back ()); } } diff --git a/lily/figured-bass-continuation.cc b/lily/figured-bass-continuation.cc index ad94209b65..45cb543821 100644 --- a/lily/figured-bass-continuation.cc +++ b/lily/figured-bass-continuation.cc @@ -34,7 +34,7 @@ Figured_bass_continuation::center_on_figures (SCM grob) { Spanner *me = dynamic_cast (unsmob_grob (grob)); extract_grob_set (me, "figures", figures); - if (figures.is_empty ()) + if (figures.empty ()) return scm_from_double (0.0); Grob *common = common_refpoint_of_array (figures, me, Y_AXIS); diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index c67cb60881..ee5517e94b 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -66,7 +66,7 @@ struct Figured_bass_engraver : public Engraver void center_continuations (Link_array const &consecutive_lines); void center_repeated_continuations (); protected: - Array groups_; + std::vector groups_; Spanner *alignment_; Link_array new_musics_; bool continuation_; @@ -86,7 +86,7 @@ protected: void Figured_bass_engraver::derived_mark () const { - for (int i = 0; i < groups_.size (); i++) + for (vsize i = 0; i < groups_.size (); i++) { scm_gc_mark (groups_[i].number_); scm_gc_mark (groups_[i].alteration_); @@ -96,13 +96,13 @@ Figured_bass_engraver::derived_mark () const void Figured_bass_engraver::stop_translation_timestep () { - if (groups_.is_empty () + if (groups_.empty () || now_mom ().main_part_ < stop_moment_.main_part_ || now_mom ().grace_part_ < Rational (0)) return ; bool found = false; - for (int i = 0; !found && i < groups_.size (); i++) + for (vsize i = 0; !found && i < groups_.size (); i++) found = found || groups_[i].current_music_; if (!found) @@ -126,10 +126,8 @@ Figured_bass_engraver::start_translation_timestep () rest_event_ = 0; new_musics_.clear (); - for (int i = 0; i < groups_.size (); i++) - { - groups_[i].current_music_ = 0; - } + for (vsize i = 0; i < groups_.size (); i++) + groups_[i].current_music_ = 0; continuation_ = false; } @@ -147,7 +145,7 @@ Figured_bass_engraver::try_music (Music *m) stop_moment_ = now_mom () + m->get_length (); SCM fig = m->get_property ("figure"); - for (int i = 0; i < groups_.size (); i++) + for (vsize i = 0; i < groups_.size (); i++) { if (!groups_[i].current_music_ && ly_is_equal (groups_[i].number_, fig)) @@ -160,7 +158,7 @@ Figured_bass_engraver::try_music (Music *m) } } - new_musics_.push (m); + new_musics_.push_back (m); return true; } @@ -172,13 +170,13 @@ Figured_bass_engraver::center_continuations (Link_array const &consecut if (consecutive_lines.size () == 2) { Link_array left_figs; - for (int j = consecutive_lines.size(); j--;) - left_figs.push (consecutive_lines[j]->get_bound (LEFT)); + for (vsize j = consecutive_lines.size(); j--;) + left_figs.push_back (consecutive_lines[j]->get_bound (LEFT)); SCM ga = Grob_array::make_array (); unsmob_grob_array (ga)->set_array (left_figs); - for (int j = consecutive_lines.size(); j--;) + for (vsize j = consecutive_lines.size(); j--;) consecutive_lines[j]->set_object ("figures", unsmob_grob_array (ga)->smobbed_copy ()); } @@ -188,18 +186,16 @@ void Figured_bass_engraver::center_repeated_continuations () { Link_array consecutive_lines; - for (int i = 0; i <= groups_.size(); i++) + for (vsize i = 0; i <= groups_.size(); i++) { if (i < groups_.size () && groups_[i].continuation_line_ - && (consecutive_lines.is_empty () + && (consecutive_lines.empty () || (consecutive_lines[0]->get_bound(LEFT)->get_column () == groups_[i].continuation_line_->get_bound (LEFT)->get_column () && consecutive_lines[0]->get_bound(RIGHT)->get_column () == groups_[i].continuation_line_->get_bound (RIGHT)->get_column ()))) - { - consecutive_lines.push (groups_[i].continuation_line_); - } + consecutive_lines.push_back (groups_[i].continuation_line_); else { center_continuations (consecutive_lines); @@ -226,25 +222,23 @@ Figured_bass_engraver::add_brackets () { Link_array encompass; bool inside = false; - for (int i = 0; i < groups_.size (); i ++) + for (vsize i = 0; i < groups_.size (); i ++) { if (!groups_[i].current_music_) continue; if (to_boolean (groups_[i].current_music_->get_property ("bracket-start"))) - { - inside = true; - } + inside = true; if (inside && groups_[i].figure_item_) - encompass.push (groups_[i].figure_item_); + encompass.push_back (groups_[i].figure_item_); if (to_boolean (groups_[i].current_music_->get_property ("bracket-stop"))) { inside = false; Item * brack = make_item ("BassFigureBracket", groups_[i].current_music_->self_scm ()); - for (int j = 0; j < encompass.size (); j++) + for (vsize j = 0; j < encompass.size (); j++) { Pointer_group_interface::add_grob (brack, ly_symbol2scm ("elements"), @@ -265,14 +259,14 @@ Figured_bass_engraver::process_music () } if (!continuation_ - && new_musics_.is_empty ()) + && new_musics_.empty ()) { clear_spanners (); return; } if (!new_music_found_) - return ; + return; new_music_found_ = false; @@ -285,7 +279,7 @@ Figured_bass_engraver::process_music () if (to_boolean (get_property ("figuredBassCenterContinuations"))) center_repeated_continuations (); alignment_ = 0; - for (int i = 0; i < groups_.size (); i++) + for (vsize i = 0; i < groups_.size (); i++) { groups_[i].group_ = 0; groups_[i].continuation_line_ = 0; @@ -293,21 +287,19 @@ Figured_bass_engraver::process_music () } if (!continuation_) - { - clear_spanners (); - } + clear_spanners (); - int k = 0; - for (int i = 0; i < new_musics_.size (); i++) + vsize k = 0; + for (vsize i = 0; i < new_musics_.size (); i++) { - while (k < groups_.size() && - groups_[k].current_music_) + while (k < groups_.size () + && groups_[k].current_music_) k++; if (k >= groups_.size ()) { Figure_group group; - groups_.push (group); + groups_.push_back (group); } groups_[k].current_music_ = new_musics_[i]; @@ -315,7 +307,7 @@ Figured_bass_engraver::process_music () k++; } - for (int i = 0; i < groups_.size (); i++) + for (vsize i = 0; i < groups_.size (); i++) { if (!groups_[i].is_continuation ()) { @@ -326,8 +318,8 @@ Figured_bass_engraver::process_music () if (use_extenders) { - Array junk_continuations; - for (int i = 0; i < groups_.size(); i++) + std::vector junk_continuations; + for (vsize i = 0; i < groups_.size(); i++) { Figure_group &group = groups_[i]; @@ -351,7 +343,7 @@ Figured_bass_engraver::process_music () } } else if (group.continuation_line_) - junk_continuations.push (i); + junk_continuations.push_back (i); } /* @@ -360,21 +352,21 @@ Figured_bass_engraver::process_music () Link_array consecutive; if (to_boolean (get_property ("figuredBassCenterContinuations"))) { - for (int i = 0; i <= junk_continuations.size (); i++) + for (vsize i = 0; i <= junk_continuations.size (); i++) { if (i < junk_continuations.size() && (i == 0 || junk_continuations[i-1] == junk_continuations[i] - 1)) - consecutive.push (groups_[junk_continuations[i]].continuation_line_); + consecutive.push_back (groups_[junk_continuations[i]].continuation_line_); else { center_continuations (consecutive); consecutive.clear (); if (i < junk_continuations.size ()) - consecutive.push (groups_[junk_continuations[i]].continuation_line_); + consecutive.push_back (groups_[junk_continuations[i]].continuation_line_); } } } - for (int i = 0; i < junk_continuations.size (); i++) + for (vsize i = 0; i < junk_continuations.size (); i++) groups_[junk_continuations[i]].continuation_line_ = 0; } @@ -394,7 +386,7 @@ Figured_bass_engraver::create_grobs () alignment_->set_bound (RIGHT, muscol); SCM proc = get_property ("figuredBassFormatter"); - for (int i = 0; i < groups_.size(); i++) + for (vsize i = 0; i < groups_.size(); i++) { Figure_group &group = groups_[i]; @@ -460,19 +452,20 @@ ADD_TRANSLATOR (Figured_bass_engraver, /* create */ "BassFigure " "BassFigureAlignment " - "BassFigureBracket", + "BassFigureBracket " "BassFigureContinuation " "BassFigureLine " - + , /* accept */ "bass-figure-event rest-event", /* read */ + "figuredBassAlterationDirection " "figuredBassCenterContinuations " - "implicitBassFigures " "figuredBassFormatter " - "figuredBassAlterationDirection " - "useBassFigureExtenders", + "implicitBassFigures " + "useBassFigureExtenders " + , /* write */ ""); diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index 117ead2c81..e45de84b14 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -36,7 +36,7 @@ Fingering_engraver::try_music (Music *m) { if (m->is_mus_type ("fingering-event")) { - events_.push (m); + events_.push_back (m); return true; } return false; @@ -45,14 +45,14 @@ Fingering_engraver::try_music (Music *m) void Fingering_engraver::acknowledge_stem (Grob_info inf) { - for (int i = 0; i < fingerings_.size (); i++) + for (vsize i = 0; i < fingerings_.size (); i++) Side_position_interface::add_support (fingerings_[i], inf.grob ()); } void Fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) { - for (int i = 0; i < fingerings_.size (); i++) + for (vsize i = 0; i < fingerings_.size (); i++) { Grob *t = fingerings_[i]; Side_position_interface::add_support (t, inf.grob ()); @@ -64,7 +64,7 @@ Fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) void Fingering_engraver::process_music () { - for (int i = events_.size (); i--;) + for (vsize i = events_.size (); i--;) { SCM dir = events_[i]->get_property ("direction"); make_script (to_dir (dir), events_[i], i); @@ -115,7 +115,7 @@ Fingering_engraver::make_script (Direction d, Music *r, int i) SCM dig = r->get_property ("digit"); fingering->set_property ("text", scm_number_to_string (dig, scm_from_int (10))); - fingerings_.push (fingering); + fingerings_.push_back (fingering); } void diff --git a/lily/font-config.cc b/lily/font-config.cc index 66aba66409..c90598b72a 100644 --- a/lily/font-config.cc +++ b/lily/font-config.cc @@ -37,12 +37,12 @@ init_fontconfig () if (!is_file ((char*)cache_file)) message (_f ("Rebuilding FontConfig cache %s. this may take a while...", cache_file)); - Array dirs; + std::vector dirs; - dirs.push (prefix_directory + "/fonts/otf/"); - dirs.push (prefix_directory + "/fonts/type1/"); + dirs.push_back (prefix_directory + "/fonts/otf/"); + dirs.push_back (prefix_directory + "/fonts/type1/"); - for (int i = 0; i < dirs.size (); i++) + for (vsize i = 0; i < dirs.size (); i++) { std::string dir = dirs[i]; if (!FcConfigAppFontAddDir (font_config_global, (FcChar8 *)dir.c_str ())) diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index 933a34b991..3e1d23cf11 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -224,7 +224,7 @@ LY_DEFINE (ly_output_formats, "ly:output-formats", "Formats passed to --format as a list of strings, " "used for the output.") { - Array output_formats = split_string (output_format_global, ','); + std::vector output_formats = split_string (output_format_global, ','); SCM lst = SCM_EOL; int output_formats_count = output_formats.size (); diff --git a/lily/global-context.cc b/lily/global-context.cc index 6c8b4e62f0..df2f1f5160 100644 --- a/lily/global-context.cc +++ b/lily/global-context.cc @@ -52,7 +52,7 @@ Global_context::add_moment_to_process (Moment m) if (m < now_mom_) programming_error ("trying to freeze in time"); - for (int i = 0; i < extra_mom_pq_.size (); i++) + for (vsize i = 0; i < extra_mom_pq_.size (); i++) if (extra_mom_pq_[i] == m) return; extra_mom_pq_.insert (m); diff --git a/lily/global-ctor.cc b/lily/global-ctor.cc index c5845be33e..e0bd749296 100644 --- a/lily/global-ctor.cc +++ b/lily/global-ctor.cc @@ -8,21 +8,21 @@ #include "global-ctor.hh" -#include "array.hh" +#include "std-vector.hh" -static Array *ctor_global_statics_; +static std::vector *ctor_global_statics_; void add_constructor (Global_ctor c) { if (!ctor_global_statics_) - ctor_global_statics_ = new Array; - ctor_global_statics_->push (c); + ctor_global_statics_ = new std::vector; + ctor_global_statics_->push_back (c); } void call_constructors () { - for (int i = 0; i < ctor_global_statics_->size (); i++) + for (vsize i = 0; i < ctor_global_statics_->size (); i++) (ctor_global_statics_->elem (i)) (); } diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 4438abd491..f9ff08b6af 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -57,9 +57,9 @@ struct Break_node }; void -print_break_nodes (Array const &arr) +print_break_nodes (std::vector const &arr) { - for (int i = 0; i < arr.size (); i++) + for (vsize i = 0; i < arr.size (); i++) { printf ("node %d: ", i); arr[i].print (); @@ -74,23 +74,23 @@ print_break_nodes (Array const &arr) TODO: should rewrite. See the function in scm/page-layout.scm for inspiration. */ -Array +std::vector Gourlay_breaking::do_solve () const { - Array optimal_paths; + std::vector optimal_paths; Link_array all = pscore_->root_system ()->columns (); - Array breaks = find_break_indices (); + std::vector breaks = find_break_indices (); Break_node first_node; - optimal_paths.push (first_node); + optimal_paths.push_back (first_node); bool ragged_right = to_boolean (pscore_->layout ()->c_variable ("raggedright")); bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("raggedlast")); Real worst_force = 0.0; - for (int break_idx = 1; break_idx < breaks.size (); break_idx++) + for (vsize break_idx = 1; break_idx < breaks.size (); break_idx++) { /* start with a short line, add measures. At some point @@ -102,12 +102,13 @@ Gourlay_breaking::do_solve () const Real minimal_demerits = infinity_f; - for (int start_idx = break_idx; start_idx--;) + for (vsize start_idx = break_idx; start_idx--;) { - Link_array line = all.slice (breaks[start_idx], breaks[break_idx] + 1); + Link_array line = all.slice (breaks[start_idx], + breaks[break_idx] + 1); line[0] = dynamic_cast (line[0])->find_prebroken_piece (RIGHT); - line.top () = dynamic_cast (line.top ())->find_prebroken_piece (LEFT); + line.back () = dynamic_cast (line.back ())->find_prebroken_piece (LEFT); Column_x_positions cp; cp.cols_ = line; @@ -172,7 +173,7 @@ Gourlay_breaking::do_solve () const bnod.line_config_ = minimal_sol; } bnod.line_ = optimal_paths[bnod.prev_break_].line_ + 1; - optimal_paths.push (bnod); + optimal_paths.push_back (bnod); if (! (break_idx % HAPPY_DOTS)) progress_indication (std::string ("[") + to_string (break_idx) + "]"); @@ -184,14 +185,14 @@ Gourlay_breaking::do_solve () const progress_indication ("\n"); - Array final_breaks; - Array lines; + std::vector final_breaks; + std::vector lines; /* skip 0-th element, since it is a "dummy" elt*/ - for (int i = optimal_paths.size () - 1; i > 0;) + for (vsize i = optimal_paths.size () - 1; i > 0;) { - final_breaks.push (i); - int prev = optimal_paths[i].prev_break_; + final_breaks.push_back (i); + vsize prev = optimal_paths[i].prev_break_; assert (i > prev); i = prev; } @@ -199,17 +200,17 @@ Gourlay_breaking::do_solve () const if (be_verbose_global) { message (_f ("Optimal demerits: %f", - optimal_paths.top ().demerits_) + "\n"); + optimal_paths.back ().demerits_) + "\n"); } - if (optimal_paths.top ().demerits_ >= infinity_f) + if (optimal_paths.back ().demerits_ >= infinity_f) warning (_ ("no feasible line breaking found")); - for (int i = final_breaks.size (); i--;) + for (vsize i = final_breaks.size (); i--;) { Column_x_positions cp (optimal_paths[final_breaks[i]].line_config_); - lines.push (cp); + lines.push_back (cp); if (!cp.satisfies_constraints_) warning (_ ("can't find line breaking that satisfies constraints")); } @@ -232,7 +233,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev, Column_x_positions const &this_one) const { Real break_penalties = 0.0; - Grob *pc = this_one.cols_.top (); + Grob *pc = this_one.cols_.back (); if (pc->original ()) { SCM pen = pc->get_property ("penalty"); diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 230a0e5425..82c84ffc4c 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -84,10 +84,10 @@ void fix_prefix_set (int *current_set, int min_set, int max_set, Grob *primitive fix_prefix ("pes_or_flexa", LINEA, current_set, min_set, max_set, primitive); } -void check_and_fix_all_prefixes (Array primitives) +void check_and_fix_all_prefixes (std::vector primitives) { /* Check for illegal head modifier combinations */ - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Grob *primitive = primitives[i].grob (); @@ -195,13 +195,13 @@ void check_and_fix_all_prefixes (Array primitives) * Marks those heads that participate in a pes or flexa. */ void -provide_context_info (Array primitives) +provide_context_info (std::vector primitives) { Grob *prev_primitive = 0; int prev_prefix_set = 0; int prev_context_info = 0; int prev_pitch = 0; - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Grob *primitive = primitives[i].grob (); Music *music_cause = primitives[i].music_cause (); @@ -242,7 +242,7 @@ provide_context_info (Array primitives) void Gregorian_ligature_engraver::build_ligature (Spanner *ligature, - Array primitives) + std::vector primitives) { // apply style-independent checking and transformation check_and_fix_all_prefixes (primitives); diff --git a/lily/grid-line-interface.cc b/lily/grid-line-interface.cc index 29ae8c4595..36dd333124 100644 --- a/lily/grid-line-interface.cc +++ b/lily/grid-line-interface.cc @@ -25,7 +25,7 @@ Grid_line_interface::print (SCM smobbed_me) Grob *refp = common_refpoint_of_array (elts, me, Y_AXIS); Interval iv; - for (int i = 0; i < elts.size (); i++) + for (vsize i = 0; i < elts.size (); i++) { Grob *point = elts[i]; diff --git a/lily/grid-line-span-engraver.cc b/lily/grid-line-span-engraver.cc index dc45a3a01c..b7daf45eac 100644 --- a/lily/grid-line-span-engraver.cc +++ b/lily/grid-line-span-engraver.cc @@ -34,7 +34,7 @@ Grid_line_span_engraver::acknowledge_grid_point (Grob_info i) if (depth) { Item *it = dynamic_cast (i.grob ()); - lines_.push (it); + lines_.push_back (it); if (lines_.size () >= 2 && !spanline_) { @@ -49,12 +49,12 @@ Grid_line_span_engraver::stop_translation_timestep () { if (spanline_) { - for (int i = 0; i < lines_.size (); i++) + for (vsize i = 0; i < lines_.size (); i++) Grid_line_interface::add_grid_point (spanline_, lines_[i]); spanline_ = 0; } - lines_.set_size (0); + lines_.resize (0); } #include "translator.icc" diff --git a/lily/grob-array-scheme.cc b/lily/grob-array-scheme.cc index 5788ef9dda..d9f7d20e98 100644 --- a/lily/grob-array-scheme.cc +++ b/lily/grob-array-scheme.cc @@ -30,11 +30,9 @@ LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref", SCM_ASSERT_TYPE (me, grob_arr, SCM_ARG1, __FUNCTION__, "Grob_array"); SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "integer"); - int i = scm_to_int (index); - if (i < 0 || i >= me->size ()) - { - scm_out_of_range (NULL, scm_from_int (i)); - } + vsize i = scm_to_unsigned (index); + if (i == VPOS || i >= me->size ()) + scm_out_of_range (NULL, scm_from_unsigned (i)); return me->grob (i)->self_scm (); } diff --git a/lily/grob-array.cc b/lily/grob-array.cc index 9f8227ad26..fba025349d 100644 --- a/lily/grob-array.cc +++ b/lily/grob-array.cc @@ -13,13 +13,13 @@ #include "ly-smobs.icc" Item * -Grob_array::item (int i) +Grob_array::item (vsize i) { return dynamic_cast (grobs_.elem (i)); } Spanner * -Grob_array::spanner (int i) +Grob_array::spanner (vsize i) { return dynamic_cast (grobs_.elem (i)); } @@ -48,7 +48,7 @@ Grob_array::mark_smob (SCM s) #if 0 /* see System::derived_mark () const */ Grob_array *ga = unsmob_grob_array (s); - for (int i = 0; i < ga->grobs_.size (); i++) + for (vsize i = 0; i < ga->grobs_.size (); i++) scm_gc_mark (ga->grobs_[i]->self_scm ()); #endif return SCM_UNDEFINED; @@ -60,7 +60,7 @@ Grob_array::print_smob (SCM arr, SCM port, scm_print_state*) scm_puts ("#size (); i++) + for (vsize i = 0; i < grob_arr->size (); i++) { scm_display (grob_arr->grob (i)->self_scm (), port); scm_puts (" ", port); @@ -83,9 +83,9 @@ Grob_array::clear () } bool -Grob_array::is_empty () const +Grob_array::empty () const { - return grobs_.is_empty (); + return grobs_.empty (); } void diff --git a/lily/grob-info.cc b/lily/grob-info.cc index e0d79af430..d8471d43f7 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -40,7 +40,7 @@ Grob_info::origin_contexts (Translator *end) const Link_array r; do { - r.push (t); + r.push_back (t); t = t->get_parent_context (); } while (t && t != end->context ()); diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index dc61fb93e6..1e55f60bde 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -32,7 +32,7 @@ protected: void start_translation_timestep (); void stop_translation_timestep (); - Array started_now_; + std::vector started_now_; }; Grob_pq_engraver::Grob_pq_engraver () @@ -82,7 +82,7 @@ Grob_pq_engraver::acknowledge_grob (Grob_info gi) e.grob_ = gi.grob (); e.end_ = end; - started_now_.push (e); + started_now_.push_back (e); } } @@ -98,7 +98,7 @@ Grob_pq_engraver::stop_translation_timestep () started_now_.sort (Grob_pq_entry::compare); SCM lst = SCM_EOL; SCM *tail = &lst; - for (int i = 0; i < started_now_.size (); i++) + for (vsize i = 0; i < started_now_.size (); i++) { *tail = scm_acons (started_now_[i].end_.smobbed_copy (), started_now_[i].grob_->self_scm (), diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index ee88f2ac48..1cfe52094b 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -208,7 +208,7 @@ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); SCM s = SCM_EOL; - for (int i = me->broken_intos_.size (); i--;) + for (vsize i = me->broken_intos_.size (); i--;) s = scm_cons (me->broken_intos_[i]->self_scm (), s); return s; } diff --git a/lily/grob.cc b/lily/grob.cc index 0ad308bdb1..c3905c4876 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -610,7 +610,7 @@ common_refpoint_of_list (SCM elist, Grob *common, Axis a) Grob * common_refpoint_of_array (Link_array const &arr, Grob *common, Axis a) { - for (int i = arr.size (); i--;) + for (vsize i = arr.size (); i--;) if (Grob *s = arr[i]) { if (common) diff --git a/lily/hairpin.cc b/lily/hairpin.cc index 199b69e719..f3911339af 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -95,7 +95,7 @@ Hairpin::print (SCM smob) { bool neighbor_found = false; extract_grob_set (me, "adjacent-hairpins", pins); - for (int i = 0; i < pins.size (); i++) + for (vsize i = 0; i < pins.size (); i++) { /* FIXME: this will fuck up in case of polyphonic diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index f8420239ee..f00434346d 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -45,7 +45,7 @@ Hara_kiri_group_spanner::consider_suicide (Grob *me) Link_array childs; Axis_group_interface::get_children (me, &childs); - for (int i = 0; i < childs.size (); i++) + 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 176b5d56ef..2babc2b033 100644 --- a/lily/horizontal-bracket-engraver.cc +++ b/lily/horizontal-bracket-engraver.cc @@ -60,7 +60,7 @@ Horizontal_bracket_engraver::try_music (Music *m) else { push_count_++; - events_.push (m); + events_.push_back (m); } if (pop_count_ && push_count_) @@ -74,7 +74,7 @@ Horizontal_bracket_engraver::try_music (Music *m) void Horizontal_bracket_engraver::acknowledge_note_column (Grob_info gi) { - for (int i = 0; i < bracket_stack_.size (); i++) + for (vsize i = 0; i < bracket_stack_.size (); i++) { Side_position_interface::add_support (bracket_stack_[i], gi.grob ()); Pointer_group_interface::add_grob (bracket_stack_[i], @@ -91,14 +91,14 @@ Horizontal_bracket_engraver::process_music () { Spanner *sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ()); - for (int i = 0; i < bracket_stack_.size (); i++) + for (vsize i = 0; i < bracket_stack_.size (); i++) { /* sp is the smallest, it should be added to the bigger brackets. */ Side_position_interface::add_support (bracket_stack_[i], sp); } - bracket_stack_.push (sp); + bracket_stack_.push_back (sp); } } diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index de6fa24b1e..e4f4f3a991 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -77,7 +77,7 @@ completize_hyphen (Spanner *sp) { extract_item_set (sp, "heads", heads); if (heads.size ()) - sp->set_bound (RIGHT, heads.top ()); + sp->set_bound (RIGHT, heads.back ()); } } diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc index fcf1ff1909..f43feee573 100644 --- a/lily/includable-lexer.cc +++ b/lily/includable-lexer.cc @@ -64,16 +64,16 @@ Includable_lexer::new_input (std::string name, Sources *sources) LexerError (msg.c_str ()); return; } - file_name_strings_.push (file->name_string ()); + file_name_strings_.push_back (file->name_string ()); - char_count_stack_.push (0); + char_count_stack_.push_back (0); if (yy_current_buffer) - state_stack_.push (yy_current_buffer); + state_stack_.push_back (yy_current_buffer); if (be_verbose_global) progress_indication (std::string ("[") + name); - include_stack_.push (file); + include_stack_.push_back (file); /* Ugh. We'd want to create a buffer from the bytes directly. @@ -87,15 +87,15 @@ Includable_lexer::new_input (std::string name, std::string data, Sources *source { Source_file *file = new Source_file (name, data); sources->add (file); - file_name_strings_.push (name); + file_name_strings_.push_back (name); - char_count_stack_.push (0); + char_count_stack_.push_back (0); if (yy_current_buffer) - state_stack_.push (yy_current_buffer); + state_stack_.push_back (yy_current_buffer); if (be_verbose_global) progress_indication (std::string ("[") + name); - include_stack_.push (file); + include_stack_.push_back (file); yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE)); } @@ -106,43 +106,44 @@ Includable_lexer::new_input (std::string name, std::string data, Sources *source bool Includable_lexer::close_input () { - include_stack_.pop (); - char_count_stack_.pop (); + include_stack_.pop_back (); + char_count_stack_.pop_back (); if (be_verbose_global) progress_indication ("]"); yy_delete_buffer (yy_current_buffer); #if HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; #endif - if (state_stack_.is_empty ()) + if (state_stack_.empty ()) { #if HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; #endif return false; } - yy_switch_to_buffer (state_stack_.pop ()); + yy_switch_to_buffer (state_stack_.back ()); + state_stack_.pop_back (); return true; } char const * Includable_lexer::here_str0 () const { - if (include_stack_.is_empty ()) + if (include_stack_.empty ()) return 0; - return include_stack_.top ()->c_str () + char_count_stack_.top (); + return include_stack_.back ()->c_str () + char_count_stack_.back (); } Includable_lexer::~Includable_lexer () { - while (!include_stack_.is_empty ()) + while (!include_stack_.empty ()) close_input (); } Source_file * Includable_lexer::get_source_file () const { - if (include_stack_.is_empty ()) + if (include_stack_.empty ()) return 0; - return include_stack_.top (); + return include_stack_.back (); } diff --git a/lily/include/accidental-interface.hh b/lily/include/accidental-interface.hh index 12c77eace2..b7154d59b5 100644 --- a/lily/include/accidental-interface.hh +++ b/lily/include/accidental-interface.hh @@ -21,7 +21,7 @@ public: static bool has_interface (Grob *); static std::string get_fontcharname (std::string style, int alteration); - static Array accurate_boxes (Grob *me, + static std::vector accurate_boxes (Grob *me, Grob **common); }; diff --git a/lily/include/beam.hh b/lily/include/beam.hh index d7bccaead9..c828ae46f3 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -73,9 +73,9 @@ 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, - Array const &stem_infos, - Array const &base_stem_ys, - Array const &stem_xs, + std::vector const &stem_infos, + std::vector const &base_stem_ys, + std::vector const &stem_xs, Real xl, Real xr, bool knee, Real yl, Real yr, Beam_quant_parameters const *); diff --git a/lily/include/beaming.hh b/lily/include/beaming.hh index 183cf337c4..19ff113571 100644 --- a/lily/include/beaming.hh +++ b/lily/include/beaming.hh @@ -28,7 +28,7 @@ struct Beaming_info */ struct Beaming_info_list { - Array infos_; + std::vector infos_; int beam_extend_count (Direction) const; int best_splitpoint_index (Moment &beat_length, bool subdivide) const; diff --git a/lily/include/bezier.hh b/lily/include/bezier.hh index 06bdd29989..2dc8ef22d6 100644 --- a/lily/include/bezier.hh +++ b/lily/include/bezier.hh @@ -24,8 +24,8 @@ public: void translate (Offset); Real get_other_coordinate (Axis a, Real x) const; - Array solve_point (Axis, Real coordinate) const; - Array solve_derivative (Offset) const; + std::vector solve_point (Axis, Real coordinate) const; + std::vector solve_derivative (Offset) const; Interval extent (Axis) const; Interval control_point_extent (Axis) const; @@ -37,15 +37,15 @@ public: /* Bezier curves always have 4 control points. Making this into an - Array<> gives unnecessary overhead, and makes debugging a royal + std::vector<> gives unnecessary overhead, and makes debugging a royal pain. */ Offset control_[4]; }; -void scale (Array *array, Real xscale, Real yscale); -void rotate (Array *array, Real phi); -void translate (Array *array, Offset o); +void scale (std::vector *array, Real xscale, Real yscale); +void rotate (std::vector *array, Real phi); +void translate (std::vector *array, Offset o); Bezier slur_shape (Real width, Real height_limit, Real height_proportion); diff --git a/lily/include/break-algorithm.hh b/lily/include/break-algorithm.hh index 829c1fc91b..9226aa621f 100644 --- a/lily/include/break-algorithm.hh +++ b/lily/include/break-algorithm.hh @@ -24,20 +24,20 @@ protected: Real linewidth_; Link_array find_breaks () const; - Array find_break_indices () const; + std::vector find_break_indices () const; void solve_line (Column_x_positions *) const; bool feasible (Link_array const &) const; Simple_spacer_wrapper *generate_spacing_problem (Link_array const &, Interval) const; - virtual Array do_solve () const = 0; + virtual std::vector do_solve () const = 0; public: virtual ~Break_algorithm (); Simple_spacer *(*get_line_spacer) (); Break_algorithm (); void set_pscore (Paper_score *); - Array solve () const; + std::vector solve () const; }; #endif // BREAK_HH diff --git a/lily/include/coherent-ligature-engraver.hh b/lily/include/coherent-ligature-engraver.hh index c5588c2db5..ede15b3e34 100644 --- a/lily/include/coherent-ligature-engraver.hh +++ b/lily/include/coherent-ligature-engraver.hh @@ -18,12 +18,12 @@ public: protected: virtual void build_ligature (Spanner *ligature, - Array primitives) = 0; + std::vector primitives) = 0; virtual void typeset_ligature (Spanner *ligature, - Array primitives); + std::vector primitives); virtual void get_set_column (Item *, Paper_column *); private: - void collect_accidentals (Spanner *, Array); + void collect_accidentals (Spanner *, std::vector); }; #endif // COHERENT_LIGATURE_ENGRAVER_HH diff --git a/lily/include/column-x-positions.hh b/lily/include/column-x-positions.hh index 152b20c627..bc49b37c91 100644 --- a/lily/include/column-x-positions.hh +++ b/lily/include/column-x-positions.hh @@ -15,7 +15,7 @@ struct Column_x_positions Link_array cols_; Link_array loose_cols_; - Array config_; + std::vector config_; Real force_; bool satisfies_constraints_; diff --git a/lily/include/engraver-group.hh b/lily/include/engraver-group.hh index 1ca9787d23..d894c9ada6 100644 --- a/lily/include/engraver-group.hh +++ b/lily/include/engraver-group.hh @@ -15,7 +15,7 @@ class Engraver_group : public virtual Translator_group { protected: - Array announce_infos_; + std::vector announce_infos_; SCM acknowledge_hash_table_; public: VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Engraver_group); diff --git a/lily/include/gourlay-breaking.hh b/lily/include/gourlay-breaking.hh index 9921f76db3..9d0e841824 100644 --- a/lily/include/gourlay-breaking.hh +++ b/lily/include/gourlay-breaking.hh @@ -16,7 +16,7 @@ */ struct Gourlay_breaking : public Break_algorithm { - Array do_solve () const; + std::vector do_solve () const; Gourlay_breaking (); Real combine_demerits (Column_x_positions const &, Column_x_positions const &) const; }; diff --git a/lily/include/gregorian-ligature-engraver.hh b/lily/include/gregorian-ligature-engraver.hh index 144dfc3274..2524d0669e 100644 --- a/lily/include/gregorian-ligature-engraver.hh +++ b/lily/include/gregorian-ligature-engraver.hh @@ -21,9 +21,9 @@ public: protected: Gregorian_ligature_engraver (); virtual bool try_music (Music *); - virtual void build_ligature (Spanner *ligature, Array primitives); + virtual void build_ligature (Spanner *ligature, std::vector primitives); virtual void transform_heads (Spanner *ligature, - Array primitives) = 0; + std::vector primitives) = 0; void stop_translation_timestep (); }; diff --git a/lily/include/grob-array.hh b/lily/include/grob-array.hh index 3886fd6b02..975301f723 100644 --- a/lily/include/grob-array.hh +++ b/lily/include/grob-array.hh @@ -24,13 +24,13 @@ class Grob_array public: bool ordered () const { return ordered_; } void set_ordered (bool b) { ordered_ = b; } - Item *item (int i); - Spanner *spanner (int i); - Grob *grob (int i) { return grobs_.elem (i); } - int size () const { return grobs_.size (); } - bool is_empty () const; + Item *item (vsize i); + Spanner *spanner (vsize i); + Grob *grob (vsize i) { return grobs_.elem (i); } + vsize size () const { return grobs_.size (); } + bool empty () const; void clear (); - void add (Grob *x) { grobs_.push (x); } + void add (Grob *x) { grobs_.push_back (x); } void set_array (Link_array const &src); Link_array &array_reference (); Link_array const &array () const; diff --git a/lily/include/includable-lexer.hh b/lily/include/includable-lexer.hh index 66c07ef78d..68fed68ebf 100644 --- a/lily/include/includable-lexer.hh +++ b/lily/include/includable-lexer.hh @@ -25,12 +25,12 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; */ class Includable_lexer : public yyFlexLexer { - Array state_stack_; + std::vector state_stack_; protected: bool close_input (); Link_array include_stack_; - Array char_count_stack_; + std::vector char_count_stack_; public: bool allow_includes_b_; @@ -39,7 +39,7 @@ public: ~Includable_lexer (); /// store dependencies for Makefile stuff. - Array file_name_strings_; + std::vector file_name_strings_; Source_file *get_source_file () const; void new_input (std::string s, Sources *); diff --git a/lily/include/keyword.hh b/lily/include/keyword.hh index cd4fa00f9a..dfd355e1af 100644 --- a/lily/include/keyword.hh +++ b/lily/include/keyword.hh @@ -7,7 +7,7 @@ #ifndef KEYWORD_HH #define KEYWORD_HH -#include "array.hh" +#include "std-vector.hh" /* for the keyword table */ struct Keyword_ent @@ -21,10 +21,10 @@ struct Keyword_ent */ struct Keyword_table { - Array table_; + std::vector table_; Keyword_table (Keyword_ent *); - int lookup (char const *s) const; + vsize lookup (char const *s) const; }; #endif // KEYWORD_HH diff --git a/lily/include/least-squares.hh b/lily/include/least-squares.hh index 296175150c..8dcb2470b6 100644 --- a/lily/include/least-squares.hh +++ b/lily/include/least-squares.hh @@ -6,13 +6,13 @@ #ifndef LEASTSQUARE_HH #define LEASTSQUARE_HH -#include "array.hh" +#include "std-vector.hh" #include "offset.hh" /** Least squares minimisation in 2 variables. */ -void minimise_least_squares (Real *coef, Real *offset, Array const &); +void minimise_least_squares (Real *coef, Real *offset, std::vector const &); #endif // LEASTSQUARE_HH diff --git a/lily/include/ligature-engraver.hh b/lily/include/ligature-engraver.hh index 1514b93510..16ce68f92b 100644 --- a/lily/include/ligature-engraver.hh +++ b/lily/include/ligature-engraver.hh @@ -25,7 +25,7 @@ protected: void process_music (); virtual Spanner *create_ligature_spanner () = 0; virtual void typeset_ligature (Spanner *ligature, - Array primitives) = 0; + std::vector primitives) = 0; virtual Spanner *current_ligature (); SCM brew_ligature_primitive_proc; @@ -37,10 +37,10 @@ private: Drul_array events_drul_; Spanner *ligature_; - Array primitives_; + std::vector primitives_; Spanner *finished_ligature_; - Array finished_primitives_; + std::vector finished_primitives_; Music *prev_start_event_; diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index cfb3cd149d..55ee32a171 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -25,11 +25,11 @@ class Lily_parser DECLARE_SMOBS (Lily_parser,); friend int yyparse (void *); - Array define_spots_; + std::vector define_spots_; char const *here_str0 () const; Simultaneous_music *get_chord (Pitch tonic, - Array *adds, Array *subs, + std::vector *adds, std::vector *subs, Pitch *inversion, Pitch *bass, Duration d); void set_chord_tremolo (int type_i); void set_last_duration (Duration const *); diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 013763485f..bb3f030b71 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -17,7 +17,7 @@ struct Lookup static Stencil dot (Offset p, Real radius); static Stencil bracket (Axis a, Interval iv, Real thick, Real protude, Real blot); static Stencil accordion (SCM arg, Real interline_f, Font_metric *fm); - static Stencil round_filled_polygon (Array const &points, Real blotdiameter); + static Stencil round_filled_polygon (std::vector const &points, Real blotdiameter); static Stencil frame (Box b, Real thick, Real blot); static Stencil slur (Bezier controls, Real cthick, Real thick); static Stencil bezier_sandwich (Bezier top_curve, Bezier bottom_curve); diff --git a/lily/include/main.hh b/lily/include/main.hh index d79b608c3e..a64b82a958 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -9,7 +9,7 @@ #define MAIN_HH #include "lily-proto.hh" -#include "array.hh" +#include "std-vector.hh" #include "std-string.hh" void debug_init (); @@ -20,13 +20,13 @@ void add_score (Score *s); void set_default_output (std::string s); std::string find_file (std::string); void call_constructors (); -Array get_inclusion_names (); -void set_inclusion_names (Array); +std::vector get_inclusion_names (); +void set_inclusion_names (std::vector); extern std::string init_name_global; /* options */ -extern Array dump_header_fieldnames_global; +extern std::vector dump_header_fieldnames_global; extern std::string output_backend_global; extern std::string output_name_global; extern bool be_safe_global; @@ -47,7 +47,7 @@ extern bool make_preview; extern bool make_print; /* misc */ -extern Array failed_files; +extern std::vector failed_files; extern int exit_status_global; extern File_path global_path; extern const char *LILYPOND_DATADIR; diff --git a/lily/include/misc.hh b/lily/include/misc.hh index 34b28a118f..4799900b6c 100644 --- a/lily/include/misc.hh +++ b/lily/include/misc.hh @@ -12,7 +12,7 @@ #include using namespace std; -#include "array.hh" +#include "std-vector.hh" #include "interval.hh" double log_2 (double x); @@ -28,7 +28,7 @@ sign (int i) else return 0; } -Array split_string (std::string s, char c); +std::vector split_string (std::string s, char c); inline Real linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2) diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index 601e5404b8..2440ae8d99 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -9,7 +9,7 @@ #ifndef MUSIC_ITERATOR_HH #define MUSIC_ITERATOR_HH -#include "array.hh" +#include "std-vector.hh" #include "moment.hh" #include "virtual-methods.hh" #include "context-handle.hh" diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index a45d3313e8..106b6645f5 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -10,7 +10,7 @@ #define PAPER_OUTPUTTER_HH #include "lily-proto.hh" -#include "array.hh" +#include "std-vector.hh" #include "std-string.hh" #include "protected-scm.hh" #include "smobs.hh" diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index f12d214de2..3056b478aa 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -28,7 +28,7 @@ public: System *root_system () const; void typeset_system (System *); - Array calc_breaking (); + std::vector calc_breaking (); SCM get_paper_systems () const; protected: diff --git a/lily/include/performer-group.hh b/lily/include/performer-group.hh index 0fb6d62108..2b83f61496 100644 --- a/lily/include/performer-group.hh +++ b/lily/include/performer-group.hh @@ -24,7 +24,7 @@ public: virtual int get_tempo () const; protected: - Array announce_infos_; + std::vector announce_infos_; private: void acknowledge_audio_elements (); diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh index 1b6742afee..cce03371f1 100644 --- a/lily/include/pitch.hh +++ b/lily/include/pitch.hh @@ -82,7 +82,7 @@ DECLARE_UNSMOB (Pitch, pitch); INSTANTIATE_COMPARE (Pitch, Pitch::compare); -int compare (Array *, Array *); +int compare (std::vector *, std::vector *); extern SCM pitch_less_proc; Pitch pitch_interval (Pitch const &from, Pitch const &to); diff --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 1ee059b637..05d3313094 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -29,7 +29,7 @@ struct Spring_description class Simple_spacer { public: - Array springs_; + std::vector springs_; Real force_; Real indent_; Real line_len_; diff --git a/lily/include/skyline.hh b/lily/include/skyline.hh index 3ca05e0ff2..f24781a750 100644 --- a/lily/include/skyline.hh +++ b/lily/include/skyline.hh @@ -9,7 +9,7 @@ #ifndef SKYLINE_HH #define SKYLINE_HH -#include "array.hh" +#include "std-vector.hh" #include "box.hh" struct Skyline_entry @@ -21,20 +21,20 @@ struct Skyline_entry }; void -merge_skyline (Array *a1, Array const &a2, +merge_skyline (std::vector *a1, std::vector const &a2, Direction); -void insert_extent_into_skyline (Array *line, Box b, Axis line_axis, +void insert_extent_into_skyline (std::vector *line, Box b, Axis line_axis, Direction d); -Array -extents_to_skyline (Array const &extents, Axis a, Direction d); -Array empty_skyline (Direction d); -void heighten_skyline (Array *buildings, Real ground); +std::vector +extents_to_skyline (std::vector const &extents, Axis a, Direction d); +std::vector empty_skyline (Direction d); +void heighten_skyline (std::vector *buildings, Real ground); Real -skyline_meshing_distance (Array const &buildings, - Array const &clouds); +skyline_meshing_distance (std::vector const &buildings, + std::vector const &clouds); Real -skyline_height (Array const &buildings, +skyline_height (std::vector const &buildings, Real airplane, Direction sky_dir); #endif /* SKYLINE_HH */ diff --git a/lily/include/slur-configuration.hh b/lily/include/slur-configuration.hh index 3039bd960c..59cc3a5368 100644 --- a/lily/include/slur-configuration.hh +++ b/lily/include/slur-configuration.hh @@ -30,7 +30,7 @@ public: Slur_configuration (); void generate_curve (Slur_score_state const &state, Real r0, Real h_inf, - Array const &); + std::vector const &); void score (Slur_score_state const &); protected: void score_extra_encompass (Slur_score_state const &); diff --git a/lily/include/slur-scoring.hh b/lily/include/slur-scoring.hh index b72f186a0f..0bb54bf7c0 100644 --- a/lily/include/slur-scoring.hh +++ b/lily/include/slur-scoring.hh @@ -105,8 +105,8 @@ struct Slur_score_state Real musical_dy_; Link_array columns_; - Array encompass_infos_; - Array extra_encompass_infos_; + std::vector encompass_infos_; + std::vector extra_encompass_infos_; Direction dir_; Slur_score_parameters parameters_; @@ -123,14 +123,14 @@ struct Slur_score_state void fill (Grob *); void set_next_direction (); - Array generate_avoid_offsets () const; + 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; Drul_array get_base_attachments () const; Drul_array get_y_attachment_range () const; Encompass_info get_encompass_info (Grob *col) const; - Array get_extra_encompass_infos () const; + std::vector get_extra_encompass_infos () const; Real move_away_from_staffline (Real y, Grob *on_staff) const; int get_closest_index (SCM inspect_quants) const; }; diff --git a/lily/include/stem.hh b/lily/include/stem.hh index bd6b297191..b9d69c7ba5 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -14,7 +14,7 @@ class Stem { public: - static Array note_head_positions (Grob *); + static std::vector note_head_positions (Grob *); static int duration_log (Grob *); static void set_beaming (Grob *, int, Direction d); static int get_beaming (Grob *, Direction d); diff --git a/lily/include/system.hh b/lily/include/system.hh index 35a0ca2713..a13f9c7da3 100644 --- a/lily/include/system.hh +++ b/lily/include/system.hh @@ -38,7 +38,7 @@ public: int element_count () const; int spanner_count () const; - void break_into_pieces (Array const &); + void break_into_pieces (std::vector const &); static bool has_interface (Grob *); Link_array broken_col_range (Item const *, Item const *) const; diff --git a/lily/include/tfm-reader.hh b/lily/include/tfm-reader.hh index 9b2c8e22d1..d2ed007268 100644 --- a/lily/include/tfm-reader.hh +++ b/lily/include/tfm-reader.hh @@ -26,8 +26,8 @@ private: void read_char_metrics (); Tex_font_char_metric read_char_metric (Char_code code); Tex_font_char_metric read_char (); - void read_lig_kern_program (Array *ligatures, - Array *kerns); + void read_lig_kern_program (std::vector *ligatures, + std::vector *kerns); Binary_source_file input_; @@ -36,8 +36,8 @@ public: Tfm_info info_; Tfm_header header_; - Array char_metrics_; - Array ascii_to_metric_idx_; + std::vector char_metrics_; + std::vector ascii_to_metric_idx_; }; #endif /* TFM_READER_HH */ diff --git a/lily/include/tfm.hh b/lily/include/tfm.hh index 85e2002029..a512080c1b 100644 --- a/lily/include/tfm.hh +++ b/lily/include/tfm.hh @@ -16,7 +16,7 @@ #ifndef TFM_HH #define TFM_HH -#include "array.hh" +#include "std-vector.hh" #include "font-metric.hh" /* The type. */ @@ -132,8 +132,8 @@ struct Tex_font_char_metric Char_code code_; Real width_, height_, depth_, italic_correction_; Fix width_fix_, height_fix_, depth_fix_, italic_correction_fix_; - Array kerns_; - Array ligatures_; + std::vector kerns_; + std::vector ligatures_; Tex_font_char_metric (); @@ -158,8 +158,8 @@ public: protected: Tfm_info info_; Tfm_header header_; - Array char_metrics_; - Array ascii_to_metric_idx_; + std::vector char_metrics_; + std::vector ascii_to_metric_idx_; SCM encoding_table_; std::string font_name_; private: diff --git a/lily/include/tie-column-format.hh b/lily/include/tie-column-format.hh index 4f47d69434..a6cb8df5eb 100644 --- a/lily/include/tie-column-format.hh +++ b/lily/include/tie-column-format.hh @@ -13,7 +13,7 @@ #include "lily-proto.hh" #include "tie-configuration.hh" -void set_chord_outline (Array *skyline, +void set_chord_outline (std::vector *skyline, Link_array bounds, Grob *common, Direction d); @@ -25,7 +25,7 @@ void final_shape_adjustment (Tie_configuration &conf, Tie_formatting_problem const&, Grob *staff_referencer); void -set_chord_outlines (Drul_array< Array > *skyline_drul, +set_chord_outlines (Drul_array< std::vector > *skyline_drul, Link_array ties, Grob *common); diff --git a/lily/include/tie-configuration.hh b/lily/include/tie-configuration.hh index e88dcabc1e..3608a94bc6 100644 --- a/lily/include/tie-configuration.hh +++ b/lily/include/tie-configuration.hh @@ -14,7 +14,7 @@ #include "direction.hh" #include "interval.hh" #include "compare.hh" -#include "array.hh" +#include "std-vector.hh" class Tie_configuration { @@ -40,7 +40,7 @@ public: INSTANTIATE_COMPARE (Tie_configuration, Tie_configuration::compare); -typedef Array Ties_configuration; +typedef std::vector Ties_configuration; #endif /* TIE_CONFIGURATION_HH */ diff --git a/lily/include/tie-formatting-problem.hh b/lily/include/tie-formatting-problem.hh index 01b44cbef4..2563e206d6 100644 --- a/lily/include/tie-formatting-problem.hh +++ b/lily/include/tie-formatting-problem.hh @@ -76,11 +76,11 @@ struct Tie_configuration_variation class Tie_formatting_problem { - Drul_array< Array > chord_outlines_; + Drul_array< std::vector > chord_outlines_; Drul_array< Box > stem_extents_; set dot_positions_; Interval dot_x_; - Array specifications_; + std::vector specifications_; Tie_configuration_map possibilities_; @@ -89,7 +89,7 @@ class Tie_formatting_problem Tie_configuration *get_configuration (int position, Direction dir); Tie_configuration *generate_configuration (int position, Direction dir) const; - Array get_variations (Ties_configuration const &ties); + std::vector get_variations (Ties_configuration const &ties); Real score_configuration (Tie_configuration const &) const; Real score_aptitude (Tie_configuration const &, Tie_specification const &) const; diff --git a/lily/include/translator-dispatch-list.hh b/lily/include/translator-dispatch-list.hh index 28549fb791..dd17643d2d 100644 --- a/lily/include/translator-dispatch-list.hh +++ b/lily/include/translator-dispatch-list.hh @@ -11,7 +11,7 @@ #include "lily-proto.hh" #include "lily-guile.hh" -#include "array.hh" +#include "std-vector.hh" #include "smobs.hh" struct Engraver_dispatch_entry @@ -22,7 +22,7 @@ struct Engraver_dispatch_entry class Engraver_dispatch_list { - Array dispatch_entries_; + std::vector dispatch_entries_; public: void apply (Grob_info); SCM static create (SCM trans_list, diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 32c080041b..3abbee33d7 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -40,7 +40,7 @@ class Translator_group { private: void precompute_method_bindings (); - Array + std::vector precomputed_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT]; Translator_group_void_method diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 2b2cb9698c..2121da90ef 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -27,7 +27,7 @@ struct Acknowledge_information NAME (); \ VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ static SCM static_description_; \ - static Array acknowledge_static_array_; \ + static std::vector acknowledge_static_array_; \ virtual void fetch_precomputable_methods (Translator_void_method_ptr methods[]); \ virtual SCM static_translator_description () const; \ virtual SCM translator_description () const; \ diff --git a/lily/include/translator.icc b/lily/include/translator.icc index 94f30f7a64..68f44c816d 100644 --- a/lily/include/translator.icc +++ b/lily/include/translator.icc @@ -9,7 +9,7 @@ #ifndef TRANSLATOR_ICC #define TRANSLATOR_ICC -#include "array.hh" +#include "std-vector.hh" #include "translator.hh" /** @@ -31,7 +31,7 @@ ADD_GLOBAL_CTOR (_ ## T ## _adder); #define ADD_TRANSLATOR(classname, desc, grobs, accepted, read, write) \ - Array classname::acknowledge_static_array_; \ + std::vector classname::acknowledge_static_array_; \ IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS (classname); \ ADD_THIS_TRANSLATOR (classname); \ Engraver_void_function_engraver_grob_info \ @@ -92,11 +92,11 @@ void add_acknowledger (Engraver_void_function_engraver_grob_info ptr, char const *func_name, - Array *ack_array); + std::vector *ack_array); Engraver_void_function_engraver_grob_info generic_get_acknowledger (SCM sym, - Array const *ack_array); + std::vector const *ack_array); #define ADD_ACKNOWLEDGER(CLASS, NAME) \ void CLASS ## NAME ## _ack_adder () \ diff --git a/lily/keyword.cc b/lily/keyword.cc index 684bc189e3..d854fbeecd 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -17,19 +17,19 @@ int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2) Keyword_table::Keyword_table (Keyword_ent *tab) { while (tab->name_) - table_.push (*tab++); + table_.push_back (*tab++); table_.sort (tabcmp); } -int +vsize Keyword_table::lookup (char const *s) const { Keyword_ent e; e.name_ = s; - int idx = binary_search (table_, e, tabcmp); - if (idx >= 0) + vsize idx = binary_search (table_, e, tabcmp); + if (idx != VPOS) return table_[idx].tokcode_; else - return -1; + return VPOS; } diff --git a/lily/laissez-vibrer-engraver.cc b/lily/laissez-vibrer-engraver.cc index ba6c837a2b..d361298c56 100644 --- a/lily/laissez-vibrer-engraver.cc +++ b/lily/laissez-vibrer-engraver.cc @@ -68,7 +68,7 @@ Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf) lv_tie); lv_tie->set_parent (lv_column_, Y_AXIS); - lv_ties_.push (lv_tie); + lv_ties_.push_back (lv_tie); } diff --git a/lily/laissez-vibrer-tie-column.cc b/lily/laissez-vibrer-tie-column.cc index 32d8a23d9e..449181e61d 100644 --- a/lily/laissez-vibrer-tie-column.cc +++ b/lily/laissez-vibrer-tie-column.cc @@ -57,7 +57,7 @@ Laissez_vibrer_tie_column::calc_positioning_done (SCM smob) problem.set_manual_tie_configuration (manual_configs); Ties_configuration base = problem.generate_optimal_chord_configuration (); - for (int i = 0; i < lv_ties.size(); i++) + for (vsize i = 0; i < lv_ties.size(); i++) { Tie::set_control_points (lv_ties[i], problem.common_x_refpoint (), base[i], problem.details_); diff --git a/lily/least-squares.cc b/lily/least-squares.cc index 79d463d184..cba93dd605 100644 --- a/lily/least-squares.cc +++ b/lily/least-squares.cc @@ -12,14 +12,14 @@ void minimise_least_squares (Real *coef, Real *offset, - Array const &input) + std::vector const &input) { Real sx = 0.0; Real sy = 0.0; Real sqx = 0.0; Real sxy = 0.0; - for (int i = 0; i < input.size ();i++) + for (vsize i = 0; i < input.size ();i++) { Real x = input[i][X_AXIS]; Real y = input[i][Y_AXIS]; diff --git a/lily/ledger-line-spanner.cc b/lily/ledger-line-spanner.cc index 43bc35b695..31fc8d0b26 100644 --- a/lily/ledger-line-spanner.cc +++ b/lily/ledger-line-spanner.cc @@ -139,7 +139,7 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) contain a lot of noteheads, superlinear performance is too slow. */ extract_item_set (me, "note-heads", heads); - for (int i = heads.size (); i--;) + for (vsize i = heads.size (); i--;) { Item *h = heads[i]; @@ -206,7 +206,7 @@ Ledger_line_spanner::print (SCM smob) extract_grob_set (me, "note-heads", heads); - if (heads.is_empty ()) + if (heads.empty ()) return SCM_EOL; // find size of note heads. @@ -231,13 +231,13 @@ Ledger_line_spanner::print (SCM smob) { Axis a = Axis (i); common[a] = common_refpoint_of_array (heads, me, a); - for (int i = heads.size (); i--;) + for (vsize i = heads.size (); i--;) if (Grob *g = unsmob_grob (me->get_object ("accidental-grob"))) common[a] = common[a]->common_refpoint (g, a); } Ledger_requests reqs; - for (int i = heads.size (); i--;) + for (vsize i = heads.size (); i--;) { Item *h = dynamic_cast (heads[i]); @@ -302,7 +302,7 @@ Ledger_line_spanner::print (SCM smob) // create ledgers for note heads Real ledgerlinethickness = Staff_symbol::get_ledger_line_thickness (staff); - for (int i = heads.size (); i--;) + for (vsize i = heads.size (); i--;) { Item *h = dynamic_cast (heads[i]); diff --git a/lily/lexer.ll b/lily/lexer.ll index 11ed6df0c6..6b418db07c 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -302,7 +302,7 @@ BOM_UTF8 \357\273\277 { yyinput (); } - char_count_stack_.top () += n; + char_count_stack_.back () += n; if (unpack_identifier (sval) != SCM_UNDEFINED) { diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc index 5fb9667015..3382193a67 100644 --- a/lily/ligature-bracket-engraver.cc +++ b/lily/ligature-bracket-engraver.cc @@ -22,7 +22,7 @@ class Ligature_bracket_engraver : public Ligature_engraver protected: virtual Spanner *create_ligature_spanner (); virtual void typeset_ligature (Spanner *ligature, - Array primitives); + std::vector primitives); DECLARE_ACKNOWLEDGER (rest); DECLARE_ACKNOWLEDGER (note_column); public: @@ -40,7 +40,7 @@ Ligature_bracket_engraver::create_ligature_spanner () } void -Ligature_bracket_engraver::typeset_ligature (Spanner *, Array) +Ligature_bracket_engraver::typeset_ligature (Spanner *, std::vector) { // no real ligature to typeset; the LigatureBracket just does it } diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index 8c77ceb456..e120095cb0 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -27,7 +27,7 @@ * * A concrete ligature engraver must subclass this class and provide * functions create_ligature_spanner () and typeset_ligature - * (Spanner *, Array). Subclasses of this class basically + * (Spanner *, std::vector). Subclasses of this class basically * fall into two categories. * * The first category consists of engravers that engrave ligatures in @@ -193,7 +193,7 @@ Ligature_engraver::acknowledge_note_head (Grob_info info) { if (ligature_) { - primitives_.push (info); + primitives_.push_back (info); if (info.grob () && (brew_ligature_primitive_proc != SCM_EOL)) { info.grob ()->set_property ("stencil", brew_ligature_primitive_proc); diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 3ab11f3ccc..6f70bae5f5 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -179,20 +179,20 @@ is_number_pair (SCM p) } typedef void (*Void_fptr) (); -Array *scm_init_funcs_; +std::vector *scm_init_funcs_; void add_scm_init_func (void (*f) ()) { if (!scm_init_funcs_) - scm_init_funcs_ = new Array; + scm_init_funcs_ = new std::vector; - scm_init_funcs_->push (f); + scm_init_funcs_->push_back (f); } void ly_init_ly_module (void *) { - for (int i = scm_init_funcs_->size (); i--;) + for (vsize i = scm_init_funcs_->size (); i--;) (scm_init_funcs_->elem (i)) (); if (be_verbose_global) @@ -356,11 +356,11 @@ ly_assoc_cdr (SCM key, SCM alist) } SCM -ly_string_array_to_scm (Array a) +ly_string_array_to_scm (std::vector a) { SCM s = SCM_EOL; - for (int i = a.size () - 1; i >= 0; i--) - s = scm_cons (ly_symbol2scm (a[i].c_str ()), s); + for (vsize i = a.size (); i ; i--) + s = scm_cons (ly_symbol2scm (a[i - 1].c_str ()), s); return s; } diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index a5c03cf736..ddf8510e9d 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -236,7 +236,7 @@ Lily_lexer::set_identifier (SCM name, SCM s) void Lily_lexer::LexerError (char const *s) { - if (include_stack_.is_empty ()) + if (include_stack_.empty ()) message (_f ("error at EOF: %s", s) + "\n"); else { @@ -285,7 +285,7 @@ Lily_lexer::add_lexed_char (int count) char const *start = here_str0 (); lexloc->set (get_source_file (), start, start + count); - char_count_stack_.top () += count; + char_count_stack_.back () += count; } #include "ly-smobs.icc" diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index 39e5c197a6..256402a841 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -121,9 +121,9 @@ Lily_parser::parse_file (std::string init, std::string name, std::string out_nam scm_set_current_module (mod); - if (!define_spots_.is_empty ()) + if (!define_spots_.empty ()) { - define_spots_.top ().warning (_ ("braces don't match")); + define_spots_.back ().warning (_ ("braces don't match")); error_level_ = 1; } @@ -148,9 +148,9 @@ Lily_parser::parse_string (std::string ly_code) do_yyparse (); scm_set_current_module (mod); - if (!define_spots_.is_empty ()) + if (!define_spots_.empty ()) { - if (define_spots_.is_empty () + if (define_spots_.empty () && !error_level_) programming_error ("define_spots_ don't match, but error_level_ not set."); } diff --git a/lily/lilypond-version.cc b/lily/lilypond-version.cc index 984c4e7c80..e12dbcbea8 100644 --- a/lily/lilypond-version.cc +++ b/lily/lilypond-version.cc @@ -10,7 +10,7 @@ #include "lilypond-input-version.hh" #include "string-convert.hh" -#include "array.hh" +#include "std-vector.hh" Lilypond_version::Lilypond_version (int major, int minor, int patch) { @@ -25,7 +25,7 @@ Lilypond_version::Lilypond_version (std::string str) minor_ = 0; patch_ = 0; - Array version; + std::vector version; version = String_convert::split (str, '.'); if (version.size () > 0 && isdigit (version[0][0])) diff --git a/lily/line-interface.cc b/lily/line-interface.cc index 420966eb8e..a9ef0fe67a 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -18,13 +18,13 @@ Line_interface::make_arrow (Offset begin, Offset end, Real length, Real width) { Real angle = (end - begin).arg (); - Array points; + std::vector points; - points.push (Offset (0, 0)); - points.push (Offset (-length, width)); - points.push (Offset (-length, -width)); + points.push_back (Offset (0, 0)); + points.push_back (Offset (-length, width)); + points.push_back (Offset (-length, -width)); - for (int i = 0; i < points.size (); i++) + for (vsize i = 0; i < points.size (); i++) points[i] = points[i] * complex_exp (Offset (0, angle)) + end; return Lookup::round_filled_polygon (points, thick); diff --git a/lily/lookup.cc b/lily/lookup.cc index 4ed1226b4c..e5fda58595 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -227,7 +227,7 @@ Lookup::round_filled_box (Box b, Real blotdiameter) * shrinked polygon). --jr */ Stencil -Lookup::round_filled_polygon (Array const &points, +Lookup::round_filled_polygon (std::vector const &points, Real blotdiameter) { /* TODO: Maybe print a warning if one of the above limitations @@ -238,7 +238,7 @@ Lookup::round_filled_polygon (Array const &points, #ifndef NDEBUG /* remove consecutive duplicate points */ - for (int i = 0; i < points.size (); i++) + for (vsize i = 0; i < points.size (); i++) { int next_i = (i + 1) % points.size (); Real d = (points[i] - points[next_i]).length (); @@ -256,10 +256,10 @@ Lookup::round_filled_polygon (Array const &points, return Line_interface::make_line (blotdiameter, points[0], points[1]); /* shrink polygon in size by 0.5 * blotdiameter */ - Array shrunk_points; - shrunk_points.set_size (points.size ()); + std::vector shrunk_points; + shrunk_points.resize (points.size ()); bool ccw = 1; // true, if three adjacent points are counterclockwise ordered - for (int i = 0; i < points.size (); i++) + for (vsize i = 0; i < points.size (); i++) { int i0 = i; int i1 = (i + 1) % points.size (); @@ -304,7 +304,7 @@ Lookup::round_filled_polygon (Array const &points, /* build scm expression and bounding box */ SCM shrunk_points_scm = SCM_EOL; Box box; - for (int i = 0; i < shrunk_points.size (); i++) + for (vsize i = 0; i < shrunk_points.size (); i++) { SCM x = scm_from_double (shrunk_points[i][X_AXIS]); SCM y = scm_from_double (shrunk_points[i][Y_AXIS]); @@ -649,7 +649,7 @@ Stencil Lookup::repeat_slash (Real w, Real s, Real t) { #if 0 /* TODO */ - Array points; + std::vector points; Real blotdiameter = 0.0; Offset p1 (0, 0); diff --git a/lily/lyric-extender.cc b/lily/lyric-extender.cc index c1aa209563..051e1231cb 100644 --- a/lily/lyric-extender.cc +++ b/lily/lyric-extender.cc @@ -57,7 +57,7 @@ Lyric_extender::print (SCM smob) = left_point + (robust_scm2double (minlen, 0)); if (heads.size ()) - right_point = max (right_point, heads.top ()->extent (common, X_AXIS)[RIGHT]); + right_point = max (right_point, heads.back ()->extent (common, X_AXIS)[RIGHT]); Real h = sl * robust_scm2double (me->get_property ("thickness"), 0); Real pad = 2* h; diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index 983a254f6d..6d2ff577ec 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -62,7 +62,7 @@ Lyric_performer::try_music (Music *event) { if (event->is_mus_type ("lyric-event")) { - events_.push (event); + events_.push_back (event); return true; } return false; diff --git a/lily/main.cc b/lily/main.cc index a99bd7908b..71e6eb22c1 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -49,7 +49,7 @@ using namespace std; */ /* Names of header fields to be dumped to a separate file. */ -Array dump_header_fieldnames_global; +std::vector dump_header_fieldnames_global; /* Name of initialisation file. */ std::string init_name_global; @@ -300,7 +300,7 @@ do_chroot_jail () USER_NAME, GROUP_NAME, JAIL, DIR, JAIL_MAX }; - Array components = String_convert::split (jail_spec, ','); + std::vector components = String_convert::split (jail_spec, ','); if (components.size () != JAIL_MAX) { error (_f ("expected %d arguments with jail, found: %d", JAIL_MAX, @@ -543,7 +543,7 @@ parse_argv (int argc, char **argv) case 'H': dump_header_fieldnames_global - .push (option_parser->optional_argument_str0_); + .push_back (option_parser->optional_argument_str0_); break; case 'I': global_path.append (option_parser->optional_argument_str0_); diff --git a/lily/melody-spanner.cc b/lily/melody-spanner.cc index 03cf137095..75a0720fc2 100644 --- a/lily/melody-spanner.cc +++ b/lily/melody-spanner.cc @@ -31,10 +31,10 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob) extract_grob_set (me, "stems", stems); - Array dirs; - for (int i = 0; i < stems.size (); i++) + std::vector dirs; + for (vsize i = 0; i < stems.size (); i++) { - dirs.push (to_dir (stems[i]->get_property ("default-direction"))); + dirs.push_back (to_dir (stems[i]->get_property ("default-direction"))); } int last_nonneutral = -1; diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc index 92bcf58405..377c4aebfc 100644 --- a/lily/mensural-ligature-engraver.cc +++ b/lily/mensural-ligature-engraver.cc @@ -46,15 +46,15 @@ class Mensural_ligature_engraver : public Coherent_ligature_engraver protected: virtual Spanner *create_ligature_spanner (); - virtual void build_ligature (Spanner *ligature, Array primitives); + virtual void build_ligature (Spanner *ligature, std::vector primitives); public: TRANSLATOR_DECLARATIONS (Mensural_ligature_engraver); private: - void transform_heads (Array primitives); - void propagate_properties (Spanner *ligature, Array primitives); - void fold_up_primitives (Array primitives); + void transform_heads (std::vector primitives); + void propagate_properties (Spanner *ligature, std::vector primitives); + void fold_up_primitives (std::vector primitives); }; Mensural_ligature_engraver::Mensural_ligature_engraver () @@ -70,7 +70,7 @@ Mensural_ligature_engraver::create_ligature_spanner () } void -Mensural_ligature_engraver::transform_heads (Array primitives) +Mensural_ligature_engraver::transform_heads (std::vector primitives) { if (primitives.size () < 2) { @@ -87,7 +87,7 @@ Mensural_ligature_engraver::transform_heads (Array primitives) bool prev_semibrevis = false; Item *prev_primitive = NULL; - for (int i = 0, s = primitives.size (); i < s; i++) + for (vsize i = 0, s = primitives.size (); i < s; i++) { Grob_info info = primitives[i]; Item *primitive = dynamic_cast (info.grob ()); @@ -296,7 +296,7 @@ Mensural_ligature_engraver::transform_heads (Array primitives) */ void Mensural_ligature_engraver::propagate_properties (Spanner *ligature, - Array primitives) + std::vector primitives) { Real thickness = robust_scm2double (ligature->get_property ("thickness"), 1.4); @@ -316,7 +316,7 @@ Mensural_ligature_engraver::propagate_properties (Spanner *ligature, Real half_flexa_width = 0.5 * (flexa_width + thickness); - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Item *primitive = dynamic_cast (primitives[i].grob ()); int output = scm_to_int (primitive->get_property ("primitive")); @@ -352,11 +352,11 @@ Mensural_ligature_engraver::propagate_properties (Spanner *ligature, } void -Mensural_ligature_engraver::fold_up_primitives (Array primitives) +Mensural_ligature_engraver::fold_up_primitives (std::vector primitives) { Item *first = 0; Real distance = 0; - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Item *current = dynamic_cast (primitives[i].grob ()); if (i == 0) @@ -375,7 +375,7 @@ Mensural_ligature_engraver::fold_up_primitives (Array primitives) void Mensural_ligature_engraver::build_ligature (Spanner *ligature, - Array primitives) + std::vector primitives) { transform_heads (primitives); propagate_properties (ligature, primitives); diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index a5fc048aa4..13bf59db8c 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -58,7 +58,7 @@ Midi_walker::do_start_note (Midi_note *note) Moment stop_mom = note->get_length () + ptr->audio_column_->at_mom (); bool play_start = true; - for (int i = 0; i < stop_note_queue.size (); i++) + for (vsize i = 0; i < stop_note_queue.size (); i++) { /* if this pith already in queue */ if (stop_note_queue[i].val->get_pitch () == note->get_pitch ()) diff --git a/lily/misc.cc b/lily/misc.cc index ee5dd51fda..9eef5ecf3a 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -35,10 +35,10 @@ log_2 (double x) return log (x) / log (2.0); } -Array +std::vector split_string (std::string s, char c) { - Array rv; + std::vector rv; while (s.length ()) { ssize i = s.find (c); @@ -52,7 +52,7 @@ split_string (std::string s, char c) if (i == NPOS) i = s.length (); - rv.push (s.substr (0, i)); + rv.push_back (s.substr (0, i)); s = s.substr (i, s.length () - i); } diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index d0f625b1c9..c429b67b48 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -69,7 +69,7 @@ Multi_measure_rest_engraver::try_music (Music *event) } else if (event->is_mus_type ("multi-measure-text-event")) { - text_events_.push (event); + text_events_.push_back (event); return true; } return false; @@ -85,11 +85,11 @@ Multi_measure_rest_engraver::process_music () Spanner *sp = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm ()); - numbers_.push (sp); + numbers_.push_back (sp); if (text_events_.size ()) { - for (int i = 0; i < text_events_.size (); i++) + for (vsize i = 0; i < text_events_.size (); i++) { Music *e = text_events_[i]; @@ -101,7 +101,7 @@ Multi_measure_rest_engraver::process_music () if (is_direction (dir)) sp->set_property ("direction", dir); - numbers_.push (sp); + numbers_.push_back (sp); } /* @@ -111,7 +111,7 @@ Multi_measure_rest_engraver::process_music () do { Grob *last = 0; - for (int i = 0; i < numbers_.size (); i++) + for (vsize i = 0; i < numbers_.size (); i++) { if (scm_from_int (d) == numbers_[i]->get_property ("direction")) { @@ -124,7 +124,7 @@ Multi_measure_rest_engraver::process_music () while (flip (&d) != DOWN); } - for (int i = 0; i < numbers_.size (); i++) + for (vsize i = 0; i < numbers_.size (); i++) { Side_position_interface::add_support (numbers_[i], mmrest_); numbers_[i]->set_parent (mmrest_, Y_AXIS); @@ -157,14 +157,14 @@ Multi_measure_rest_engraver::stop_translation_timestep () if (last_rest_) { add_bound_item (last_rest_, last_command_item_); - for (int i = 0; i < last_numbers_.size (); i++) + for (vsize i = 0; i < last_numbers_.size (); i++) add_bound_item (last_numbers_[i], last_command_item_); } if (mmrest_) { add_bound_item (mmrest_, last_command_item_); - for (int i = 0; i < numbers_.size (); i++) + for (vsize i = 0; i < numbers_.size (); i++) add_bound_item (numbers_[i], last_command_item_); last_command_item_ = 0; diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 0b796673e8..9c1bb10d7d 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -43,9 +43,9 @@ struct Finger_tuple class New_fingering_engraver : public Engraver { - Array fingerings_; - Array articulations_; - Array string_numbers_; + std::vector fingerings_; + std::vector articulations_; + std::vector string_numbers_; Link_array heads_; Grob *stem_; @@ -59,7 +59,7 @@ protected: void add_fingering (Grob *, Music *, Music *); void add_script (Grob *, Music *, Music *); void add_string (Grob *, Music *, Music *); - void position_scripts (SCM orientations, Array *); + void position_scripts (SCM orientations, std::vector *); }; void @@ -95,7 +95,7 @@ New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) } } - heads_.push (inf.grob ()); + heads_.push_back (inf.grob ()); } void @@ -119,7 +119,7 @@ New_fingering_engraver::add_script (Grob *head, { ft.script_ = g; - articulations_.push (ft); + articulations_.push_back (ft); ft.script_->set_parent (head, X_AXIS); } @@ -159,7 +159,7 @@ New_fingering_engraver::add_fingering (Grob *head, ft.note_event_ = hevent; ft.head_ = head; - fingerings_.push (ft); + fingerings_.push_back (ft); } void @@ -182,14 +182,14 @@ New_fingering_engraver::add_string (Grob *head, ft.note_event_ = hevent; ft.head_ = head; - string_numbers_.push (ft); + string_numbers_.push_back (ft); } void New_fingering_engraver::position_scripts (SCM orientations, - Array *scripts) + std::vector *scripts) { - for (int i = 0; i < scripts->size (); i++) + for (vsize i = 0; i < scripts->size (); i++) if (stem_ && to_boolean (scripts->elem (i).script_->get_property ("add-stem-support"))) Side_position_interface::add_support (scripts->elem (i).script_, stem_); @@ -202,20 +202,20 @@ New_fingering_engraver::position_scripts (SCM orientations, to the note head, and write a more flexible function for positioning the fingerings, setting both X and Y coordinates. */ - for (int i = 0; i < scripts->size (); i++) + for (vsize i = 0; i < scripts->size (); i++) (*scripts)[i].position_ = scm_to_int ((*scripts)[i].head_->get_property ("staff-position")); - for (int i = scripts->size (); i--;) - for (int j = heads_.size (); j--;) + for (vsize i = scripts->size (); i--;) + for (vsize j = heads_.size (); j--;) Side_position_interface::add_support ((*scripts)[i].script_, heads_[j]); - Array up, down, horiz; - for (int i = scripts->size (); i--;) + std::vector up, down, horiz; + for (vsize i = scripts->size (); i--;) { SCM d = (*scripts)[i].finger_event_->get_property ("direction"); if (to_dir (d)) { - ((to_dir (d) == UP) ? up : down).push ((*scripts)[i]); + ((to_dir (d) == UP) ? up : down).push_back ((*scripts)[i]); scripts->del (i); } } @@ -230,11 +230,14 @@ New_fingering_engraver::position_scripts (SCM orientations, if (left_p || right_p) { if (up_p && !up.size () && scripts->size ()) - up.push (scripts->pop ()); + { + up.push_back (scripts->back ()); + scripts->pop_back (); + } if (down_p && !down.size () && scripts->size ()) { - down.push ((*scripts)[0]); + down.push_back ((*scripts)[0]); scripts->del (0); } @@ -262,7 +265,7 @@ New_fingering_engraver::position_scripts (SCM orientations, scripts->clear (); } - for (int i = 0; i < horiz.size (); i++) + for (vsize i = 0; i < horiz.size (); i++) { Finger_tuple ft = horiz[i]; Grob *f = ft.script_; @@ -279,10 +282,10 @@ New_fingering_engraver::position_scripts (SCM orientations, int finger_prio = 200; Direction d = DOWN; - Drul_array< Array > vertical (down, up); + Drul_array< std::vector > vertical (down, up); do { - for (int i = 0; i < vertical[d].size (); i++) + for (vsize i = 0; i < vertical[d].size (); i++) { Finger_tuple ft = vertical[d][i]; Grob *f = ft.script_; @@ -317,11 +320,11 @@ New_fingering_engraver::stop_translation_timestep () string_numbers_.clear (); } - for (int i = articulations_.size (); i--;) + for (vsize i = articulations_.size (); i--;) { Grob *script = articulations_[i].script_; - for (int j = heads_.size (); j--;) + for (vsize j = heads_.size (); j--;) Side_position_interface::add_support (script, heads_[j]); if (stem_ && to_dir (script->get_property ("side-relative-direction"))) diff --git a/lily/note-collision.cc b/lily/note-collision.cc index 284810d6ec..e7a6c621c8 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -23,8 +23,8 @@ void check_meshing_chords (Grob *me, - Drul_array > *offsets, - Drul_array > const &extents, + Drul_array > *offsets, + Drul_array > const &extents, Drul_array > const &clash_groups) { @@ -41,15 +41,15 @@ check_meshing_chords (Grob *me, Grob *nu = Note_column::first_head (cu); Grob *nd = Note_column::first_head (cd); - Array ups = Stem::note_head_positions (Note_column::get_stem (cu)); - Array dps = Stem::note_head_positions (Note_column::get_stem (cd)); + std::vector ups = Stem::note_head_positions (Note_column::get_stem (cu)); + std::vector dps = Stem::note_head_positions (Note_column::get_stem (cd)); /* Too far apart to collide. */ - if (ups[0] > dps.top () + 1) + if (ups[0] > dps.back () + 1) return; // FIXME: what's this? - bool merge_possible = (ups[0] >= dps[0]) && (ups.top () >= dps.top ()); + bool merge_possible = (ups[0] >= dps[0]) && (ups.back () >= dps.back ()); /* Do not merge notes typeset in different style. */ if (!ly_is_equal (nu->get_property ("style"), @@ -127,8 +127,7 @@ check_meshing_chords (Grob *me, bool distant_half_collide = false; bool full_collide = false; - int i = 0, j = 0; - while (i < ups.size () && j < dps.size ()) + for (vsize i = 0, j = 0; i < ups.size () && j < dps.size (); ) { if (abs (ups[i] - dps[j]) == 1) { @@ -140,9 +139,9 @@ check_meshing_chords (Grob *me, } else if (ups[i] == dps[j]) full_collide = true; - else if (ups[i] > dps[0] && ups[i] < dps.top ()) + else if (ups[i] > dps[0] && ups[i] < dps.back ()) merge_possible = false; - else if (dps[j] > ups[0] && dps[j] < ups.top ()) + else if (dps[j] > ups[0] && dps[j] < ups.back ()) merge_possible = false; if (ups[i] < dps[j]) @@ -165,7 +164,7 @@ check_meshing_chords (Grob *me, Real shift_amount = 1; - bool touch = (ups[0] >= dps.top ()); + bool touch = (ups[0] >= dps.back ()); if (touch) shift_amount *= -1; @@ -269,7 +268,7 @@ check_meshing_chords (Grob *me, Direction d = UP; do { - for (int i = 0; i < clash_groups[d].size (); i++) + for (vsize i = 0; i < clash_groups[d].size (); i++) (*offsets)[d][i] += d * shift_amount; } while ((flip (&d)) != UP); @@ -286,7 +285,7 @@ Note_collision_interface::calc_positioning_done (SCM smob) Direction d = UP; do { - for (int i = cg[d].size(); i--; ) + for (vsize i = cg[d].size(); i--; ) { /* Trigger positioning @@ -313,14 +312,14 @@ Note_collision_interface::calc_positioning_done (SCM smob) Link_array done; Real left_most = 1e6; - Array amounts; + std::vector amounts; for (; scm_is_pair (hand); hand = scm_cdr (hand)) { Grob *s = unsmob_grob (scm_caar (hand)); Real amount = scm_to_double (scm_cdar (hand)) * wid; - done.push (s); - amounts.push (amount); + done.push_back (s); + amounts.push_back (amount); if (amount < left_most) left_most = amount; } @@ -331,14 +330,14 @@ Note_collision_interface::calc_positioning_done (SCM smob) if (!done.find (s)) { - done.push (s); - amounts.push (amount); + done.push_back (s); + amounts.push_back (amount); if (amount < left_most) left_most = amount; } } - for (int i = 0; i < amounts.size (); i++) + for (vsize i = 0; i < amounts.size (); i++) done[i]->translate_axis (amounts[i] - left_most, X_AXIS); return SCM_BOOL_T; @@ -350,11 +349,11 @@ Note_collision_interface::get_clash_groups (Grob *me) Drul_array > clash_groups; extract_grob_set (me, "elements", elements); - for (int i = 0; i < elements.size (); i++) + for (vsize i = 0; i < elements.size (); i++) { Grob *se = elements[i]; if (Note_column::has_interface (se)) - clash_groups[Note_column::dir (se)].push (se); + clash_groups[Note_column::dir (se)].push_back (se); } Direction d = UP; @@ -378,27 +377,27 @@ Note_collision_interface::automatic_shift (Grob *me, Drul_array < Link_array > clash_groups) { - Drul_array < Array > shifts; + Drul_array < std::vector > shifts; SCM tups = SCM_EOL; Direction d = UP; do { - Array &shift (shifts[d]); + std::vector &shift (shifts[d]); Link_array &clashes (clash_groups[d]); - for (int i = 0; i < clashes.size (); i++) + for (vsize i = 0; i < clashes.size (); i++) { SCM sh = clashes[i]->get_property ("horizontal-shift"); if (scm_is_number (sh)) - shift.push (scm_to_int (sh)); + shift.push_back (scm_to_int (sh)); else - shift.push (0); + shift.push_back (0); } - for (int i = 1; i < shift.size (); i++) + for (vsize i = 1; i < shift.size (); i++) { if (shift[i - 1] == shift[i]) { @@ -409,18 +408,18 @@ Note_collision_interface::automatic_shift (Grob *me, } while ((flip (&d)) != UP); - Drul_array > extents; - Drul_array > offsets; + Drul_array > extents; + Drul_array > offsets; d = UP; do { - for (int i = 0; i < clash_groups[d].size (); i++) + for (vsize i = 0; i < clash_groups[d].size (); i++) { Slice s (Note_column::head_positions_interval (clash_groups[d][i])); s[LEFT]--; s[RIGHT]++; - extents[d].push (s); - offsets[d].push (d * 0.5 * i); + extents[d].push_back (s); + offsets[d].push_back (d * 0.5 * i); } } while ((flip (&d)) != UP); @@ -436,13 +435,13 @@ Note_collision_interface::automatic_shift (Grob *me, do { - for (int i = 1; i < clash_groups[d].size (); i++) + for (vsize i = 1; i < clash_groups[d].size (); i++) { Slice prev = extents[d][i - 1]; prev.intersect (extents[d][i]); if (prev.length () > 0 || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0)) - for (int j = i; j < clash_groups[d].size (); j++) + for (vsize j = i; j < clash_groups[d].size (); j++) offsets[d][j] += d * 0.5; } } @@ -456,7 +455,7 @@ Note_collision_interface::automatic_shift (Grob *me, do { - for (int i = 0; i < clash_groups[d].size (); i++) + for (vsize i = 0; i < clash_groups[d].size (); i++) tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), scm_from_double (offsets[d][i])), tups); @@ -472,7 +471,7 @@ Note_collision_interface::forced_shift (Grob *me) SCM tups = SCM_EOL; extract_grob_set (me, "elements", elements); - for (int i = 0; i < elements.size (); i++) + for (vsize i = 0; i < elements.size (); i++) { Grob *se = elements[i]; diff --git a/lily/note-column.cc b/lily/note-column.cc index 8d4204b674..ba8ebd6fd8 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -60,7 +60,7 @@ Note_column::head_positions_interval (Grob *me) iv.set_empty (); extract_grob_set (me, "note-heads", heads); - for (int i = 0; i < heads.size (); i++) + for (vsize i = 0; i < heads.size (); i++) { Grob *se = heads[i]; @@ -162,7 +162,7 @@ Note_column::accidentals (Grob *me) { extract_grob_set (me, "note-heads", heads); Grob *acc = 0; - for (int i = 0; i < heads.size (); i++) + for (vsize i = 0; i < heads.size (); i++) { Grob *h = heads[i]; acc = h ? unsmob_grob (h->get_object ("accidental-grob")) : 0; diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 2aa23935b7..3a8705168c 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -42,7 +42,7 @@ Note_heads_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { - note_evs_.push (m); + note_evs_.push_back (m); return true; } else if (m->is_mus_type ("busy-playing-event")) @@ -54,7 +54,7 @@ Note_heads_engraver::try_music (Music *m) void Note_heads_engraver::process_music () { - for (int i = 0; i < note_evs_.size (); i++) + for (vsize i = 0; i < note_evs_.size (); i++) { Music *ev = note_evs_[i]; Item *note = make_item ("NoteHead", ev->self_scm ()); @@ -73,7 +73,7 @@ Note_heads_engraver::process_music () d->set_parent (note, Y_AXIS); - dots_.push (d); + dots_.push_back (d); } Pitch *pit = unsmob_pitch (ev->get_property ("pitch")); @@ -112,7 +112,7 @@ Note_heads_engraver::process_music () note->set_property ("style", style); } - notes_.push (note); + notes_.push_back (note); } } diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index b464eeefcf..1fc63b0242 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -26,7 +26,7 @@ Note_name_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { - events_.push (m); + events_.push_back (m); return true; } return false; @@ -36,7 +36,7 @@ void Note_name_engraver::process_music () { std::string s; - for (int i = 0; i < events_.size (); i++) + for (vsize i = 0; i < events_.size (); i++) { if (i) s += " "; @@ -51,7 +51,7 @@ Note_name_engraver::process_music () { Item *t = make_item ("NoteName", events_[0]->self_scm ()); t->set_property ("text", scm_makfrom0str (s.c_str ())); - texts_.push (t); + texts_.push_back (t); } } diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 28ff54d2b5..77c0a21bf8 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -53,7 +53,7 @@ Note_performer::process_music () Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing); Audio_element_info info (p, n); announce_element (info); - notes_.push (p); + notes_.push_back (p); } } note_evs_.clear (); @@ -66,7 +66,7 @@ Note_performer::stop_translation_timestep () // why don't grace notes show up here? // --> grace notes effectively do not get delayed Moment now = now_mom (); - for (int i = 0; i < notes_.size (); i++) + for (vsize i = 0; i < notes_.size (); i++) play_element (notes_[i]); notes_.clear (); note_evs_.clear (); @@ -77,7 +77,7 @@ Note_performer::try_music (Music *ev) { if (ev->is_mus_type ("note-event")) { - note_evs_.push (ev); + note_evs_.push_back (ev); return true; } else if (ev->is_mus_type ("busy-playing-event")) diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index d42d7ced16..8206b3b4e9 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -40,7 +40,7 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, do { Link_array const &items (ly_scm2link_array (props [d])); - for (int i = items.size (); i--;) + for (vsize i = items.size (); i--;) { Item *it = dynamic_cast (items[i]); @@ -204,7 +204,7 @@ Note_spacing::right_column (Grob *me) Item *mincol = 0; int min_rank = INT_MAX; bool prune = false; - for (int i = 0; a && i < a->size (); i++) + for (vsize i = 0; a && i < a->size (); i++) { Item *ri = a->item (i); Item *col = ri->get_column (); @@ -224,7 +224,7 @@ Note_spacing::right_column (Grob *me) if (prune && a) { Link_array &right = a->array_reference (); - for (int i = right.size (); i--;) + for (vsize i = right.size (); i--;) { if (dynamic_cast (right[i])->get_column () != mincol) right.del (i); @@ -270,7 +270,7 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, do { Link_array const &items (ly_scm2link_array (props [d])); - for (int i = 0; i < items.size (); i++) + for (vsize i = 0; i < items.size (); i++) { Item *it = dynamic_cast (items[i]); diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index 3c0cfc2c7c..f3b90b124c 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -55,7 +55,7 @@ Ottava_bracket::print (SCM smob) { extract_grob_set (b, "note-heads", heads); common = common_refpoint_of_array (heads, common, X_AXIS); - for (int i = 0; i < heads.size (); i++) + for (vsize i = 0; i < heads.size (); i++) { Grob *h = heads[i]; Grob *dots = Rhythmic_head::get_dots (h); @@ -87,7 +87,7 @@ Ottava_bracket::print (SCM smob) if (Note_column::has_interface (b)) { extract_grob_set (b, "note-heads", heads); - for (int i = 0; i < heads.size (); i++) + for (vsize i = 0; i < heads.size (); i++) { Grob *h = heads[i]; ext.unite (h->extent (common, X_AXIS)); diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 8e57ddf1d2..d3eeccedfc 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -31,7 +31,7 @@ Output_property_engraver::try_music (Music* m) { if (m->is_mus_type ("layout-instruction")) { - props_.push (m); + props_.push_back (m); return true; } return false; @@ -40,7 +40,7 @@ Output_property_engraver::try_music (Music* m) void Output_property_engraver::acknowledge_grob (Grob_info inf) { - for (int i = props_.size (); i--;) + for (vsize i = props_.size (); i--;) { Music *o = props_[i]; Context *d = inf.context (); diff --git a/lily/pango-select.cc b/lily/pango-select.cc index 6f832e7621..5c93c1386c 100644 --- a/lily/pango-select.cc +++ b/lily/pango-select.cc @@ -43,8 +43,7 @@ properties_to_pango_description (SCM chain, Real text_size) 0.0); Real size = text_size * pow (2.0, step / 6.0); - pango_font_description_set_size (description, - gint (size * PANGO_SCALE)); + pango_font_description_set_size (description, gint (size * PANGO_SCALE)); return description; } diff --git a/lily/paper-book.cc b/lily/paper-book.cc index bf12566460..0677be700c 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -65,7 +65,7 @@ SCM dump_fields () { SCM fields = SCM_EOL; - for (int i = dump_header_fieldnames_global.size (); i--;) + for (vsize i = dump_header_fieldnames_global.size (); i--;) fields = scm_cons (ly_symbol2scm (dump_header_fieldnames_global[i].c_str ()), fields); diff --git a/lily/paper-column-engraver.cc b/lily/paper-column-engraver.cc index 9076080653..13cc58fedd 100644 --- a/lily/paper-column-engraver.cc +++ b/lily/paper-column-engraver.cc @@ -71,7 +71,7 @@ Paper_column_engraver::initialize () void Paper_column_engraver::acknowledge_item (Grob_info gi) { - items_.push (gi.item ()); + items_.push_back (gi.item ()); } void @@ -168,7 +168,7 @@ Paper_column_engraver::process_music () void Paper_column_engraver::stop_translation_timestep () { - for (int i = 0; i < items_.size (); i++) + for (vsize i = 0; i < items_.size (); i++) { Item *elem = items_[i]; if (!elem->get_parent (X_AXIS) diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 9993b029ed..3094f81759 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -159,7 +159,7 @@ Paper_column::before_line_breaking (SCM grob) Link_array &array (ga->array_reference ()); - for (int i = array.size (); i--;) + for (vsize i = array.size (); i--;) { Grob *g = array[i]; diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 4247732273..6bc05c4e13 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -58,11 +58,11 @@ Paper_score::typeset_system (System *system) system->unprotect (); } -Array +std::vector Paper_score::calc_breaking () { Break_algorithm *algorithm = 0; - Array sol; + std::vector sol; algorithm = new Gourlay_breaking; algorithm->set_pscore (this); @@ -88,11 +88,11 @@ Paper_score::process () doubly, also done in Score_engraver */ Link_array pc (system_->columns ()); pc[0]->set_property ("breakable", SCM_BOOL_T); - pc.top ()->set_property ("breakable", SCM_BOOL_T); + pc.back ()->set_property ("breakable", SCM_BOOL_T); system_->pre_processing (); - Array breaking = calc_breaking (); + std::vector breaking = calc_breaking (); system_->break_into_pieces (breaking); paper_systems_ = system_->get_paper_systems (); diff --git a/lily/performance.cc b/lily/performance.cc index 695bb399f7..93899350e0 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -48,7 +48,7 @@ Performance::output (Midi_stream &midi_stream) output_header_track (midi_stream); message (_ ("Track...") + " "); int channel = 0; - for (int i = 0; i < audio_staffs_.size (); i++) + for (vsize i = 0; i < audio_staffs_.size (); i++) { Audio_staff *s = audio_staffs_[i]; if (be_verbose_global) @@ -145,7 +145,7 @@ void Performance::add_element (Audio_element *p) { if (Audio_staff *s = dynamic_cast (p)) - audio_staffs_.push (s); + audio_staffs_.push_back (s); audio_element_list_ = new Killing_cons (p, audio_element_list_); } diff --git a/lily/performer-group.cc b/lily/performer-group.cc index 0e1949657f..9e71c6e762 100644 --- a/lily/performer-group.cc +++ b/lily/performer-group.cc @@ -23,7 +23,7 @@ ADD_TRANSLATOR_GROUP (Performer_group, void Performer_group::announce_element (Audio_element_info info) { - announce_infos_.push (info); + announce_infos_.push_back (info); Translator_group *t = context ()->get_parent_context ()->implementation (); @@ -34,7 +34,7 @@ Performer_group::announce_element (Audio_element_info info) void Performer_group::acknowledge_audio_elements () { - for (int j = 0; j < announce_infos_.size (); j++) + for (vsize j = 0; j < announce_infos_.size (); j++) { Audio_element_info info = announce_infos_[j]; diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index 4194be280f..b8eed4092d 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -72,7 +72,7 @@ Phrasing_slur_engraver::try_music (Music *m) } else if (d == STOP) { - if (slurs_.is_empty ()) + if (slurs_.empty ()) return false; events_[STOP] = m; @@ -86,9 +86,9 @@ void Phrasing_slur_engraver::acknowledge_note_column (Grob_info info) { Grob *e = info.grob (); - for (int i = slurs_.size (); i--;) + for (vsize i = slurs_.size (); i--;) Slur::add_column (slurs_[i], e); - for (int i = end_slurs_.size (); i--;) + for (vsize i = end_slurs_.size (); i--;) Slur::add_column (end_slurs_[i], e); } @@ -101,9 +101,9 @@ Phrasing_slur_engraver::acknowledge_extra_object (Grob_info info) if (Tie::has_interface (e) || avoid == ly_symbol2scm ("inside")) { - for (int i = slurs_.size (); i--;) + for (vsize i = slurs_.size (); i--;) Slur::add_extra_encompass (slurs_[i], e); - for (int i = end_slurs_.size (); i--;) + for (vsize i = end_slurs_.size (); i--;) Slur::add_extra_encompass (end_slurs_[i], e); } else if (avoid == ly_symbol2scm ("outside") @@ -179,7 +179,7 @@ Phrasing_slur_engraver::process_music () slurs_.clear (); } - if (events_[START] && slurs_.is_empty ()) + if (events_[START] && slurs_.empty ()) { Music *ev = events_[START]; @@ -188,7 +188,7 @@ Phrasing_slur_engraver::process_music () if (updown) set_grob_direction (slur, updown); - slurs_.push (slur); + slurs_.push_back (slur); } } diff --git a/lily/piano-pedal-bracket.cc b/lily/piano-pedal-bracket.cc index 01b51357ff..b0caa70f12 100644 --- a/lily/piano-pedal-bracket.cc +++ b/lily/piano-pedal-bracket.cc @@ -48,7 +48,8 @@ Piano_pedal_bracket::print (SCM smob) if (broken[d]) { if (orig - && ((d == RIGHT && me->get_break_index () != orig->broken_intos_.size () - 1) + && ((d == RIGHT + && me->get_break_index () != orig->broken_intos_.size () - 1) || (d == LEFT && me->get_break_index ()))) height[d] = 0.0; else diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 716f5a4742..646c7e79d4 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -264,8 +264,8 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) if (previous_.size ()) // add extra space below the previous already-occuring pedal Side_position_interface::add_support (p->line_spanner_, - previous_.top ()); - previous_.push (p->line_spanner_); + previous_.back ()); + previous_.push_back (p->line_spanner_); } } @@ -386,9 +386,9 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) // position new pedal spanner below the current one */ if (previous_.size ()) - Side_position_interface::add_support (p->line_spanner_, previous_.top ()); + Side_position_interface::add_support (p->line_spanner_, previous_.back ()); - previous_.push (p->line_spanner_); + previous_.push_back (p->line_spanner_); } } diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 0edfcfb997..f4ac60018a 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -85,7 +85,7 @@ Piano_pedal_performer::process_music () Audio_piano_pedal *a = new Audio_piano_pedal; a->type_string_ = std::string (p->name_); a->dir_ = STOP; - audios_.push (a); + audios_.push_back (a); Audio_element_info info(a, p->event_drul_[STOP]); announce_element (info); } @@ -98,7 +98,7 @@ Piano_pedal_performer::process_music () Audio_piano_pedal *a = new Audio_piano_pedal; a->type_string_ = std::string (p->name_); a->dir_ = START; - audios_.push (a); + audios_.push_back (a); Audio_element_info info(a, p->event_drul_[START]); announce_element (info); } @@ -110,7 +110,7 @@ Piano_pedal_performer::process_music () void Piano_pedal_performer::stop_translation_timestep () { - for (int i = 0; i < audios_.size (); i++) + for (vsize i = 0; i < audios_.size (); i++) play_element (audios_[i]); audios_.clear (); } diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index 302c90b9f0..ec983e5d0c 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -50,12 +50,12 @@ Pitched_trill_engraver::Pitched_trill_engraver () void Pitched_trill_engraver::acknowledge_dots (Grob_info info) { - heads_.push (info.grob ()); + heads_.push_back (info.grob ()); } void Pitched_trill_engraver::acknowledge_note_head (Grob_info info) { - heads_.push (info.grob ()); + heads_.push_back (info.grob ()); } void @@ -122,7 +122,7 @@ void Pitched_trill_engraver::stop_translation_timestep () { if (trill_group_) - for (int i = 0; i < heads_.size (); i++) + for (vsize i = 0; i < heads_.size (); i++) Side_position_interface::add_support (trill_group_, heads_[i]); heads_.clear (); diff --git a/lily/pointer-group-interface.cc b/lily/pointer-group-interface.cc index 4daaff0595..967c4ccec6 100644 --- a/lily/pointer-group-interface.cc +++ b/lily/pointer-group-interface.cc @@ -60,8 +60,8 @@ internal_extract_item_array (Grob const *elt, SCM symbol) { Grob_array *arr = unsmob_grob_array (elt->internal_get_object (symbol)); Link_array items; - for (int i = 0; arr && i < arr->size (); i++) - items.push (arr->item (i)); + for (vsize i = 0; arr && i < arr->size (); i++) + items.push_back (arr->item (i)); return items; } diff --git a/lily/program-option.cc b/lily/program-option.cc index dc53b307ad..9a756af0ed 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -93,7 +93,7 @@ get_help_string () SCM alist = ly_hash2alist (option_hash); SCM convertor = ly_lily_module_constant ("scm->string"); - Array opts; + std::vector opts; for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) { @@ -122,12 +122,12 @@ get_help_string () std::string ("\n") + String_convert::char_string (' ', HELP_INDENT)); - opts.push (opt_spec + opt_help + "\n"); + opts.push_back (opt_spec + opt_help + "\n"); } std::string help ("Options supported by ly:set-option\n\n"); opts.sort (string_compare); - for (int i = 0; i < opts.size (); i++) + for (vsize i = 0; i < opts.size (); i++) help += opts[i]; help += std::string ("\n"); diff --git a/lily/relocate.cc b/lily/relocate.cc index 1565eb4971..4e5669c7aa 100644 --- a/lily/relocate.cc +++ b/lily/relocate.cc @@ -271,18 +271,18 @@ setup_paths (char const *argv0_ptr) char *suffixes[] = {"ly", "ps", "scm", 0 }; - Array dirs; + std::vector dirs; for (char **s = suffixes; *s; s++) { std::string path = prefix_directory + to_string ('/') + std::string (*s); - dirs.push (path); + dirs.push_back (path); } - dirs.push (prefix_directory + "/fonts/otf/"); - dirs.push (prefix_directory + "/fonts/type1/"); - dirs.push (prefix_directory + "/fonts/svg/"); + dirs.push_back (prefix_directory + "/fonts/otf/"); + dirs.push_back (prefix_directory + "/fonts/type1/"); + dirs.push_back (prefix_directory + "/fonts/svg/"); - for (int i = 0; i < dirs.size (); i++) + for (vsize i = 0; i < dirs.size (); i++) global_path.prepend (dirs[i]); } diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index 5a6aa6cfbf..2d2b6df053 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -34,7 +34,7 @@ void Rest_collision_engraver::process_acknowledged () { if (rest_collision_ - || note_columns_.is_empty () + || note_columns_.empty () || !rest_count_ || (note_columns_.size () == rest_count_ && rest_count_ < 2)) @@ -42,14 +42,14 @@ Rest_collision_engraver::process_acknowledged () rest_collision_ = make_item ("RestCollision", SCM_EOL); - for (int i = 0; i < note_columns_.size (); i++) + for (vsize i = 0; i < note_columns_.size (); i++) Rest_collision::add_column (rest_collision_, note_columns_[i]); } void Rest_collision_engraver::acknowledge_note_column (Grob_info i) { - note_columns_.push (i.grob ()); + note_columns_.push_back (i.grob ()); if (Note_column::has_rests (i.grob ())) rest_count_++; } diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 1bd6f7924e..1921aa5a17 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -95,7 +95,7 @@ Rest_collision::calc_positioning_done (SCM smob) Link_array rests; Link_array notes; - for (int i = 0; i < elts.size (); i++) + for (vsize i = 0; i < elts.size (); i++) { Grob *e = elts[i]; if (unsmob_grob (e->get_object ("rest"))) @@ -107,10 +107,10 @@ Rest_collision::calc_positioning_done (SCM smob) if (st && unsmob_grob (st->get_object ("beam"))) continue; - rests.push (e); + rests.push_back (e); } else - notes.push (e); + notes.push_back (e); } /* @@ -138,13 +138,13 @@ Rest_collision::calc_positioning_done (SCM smob) center one should be centered on the staff. */ Drul_array > ordered_rests; - for (int i = 0; i < rests.size (); i++) + for (vsize i = 0; i < rests.size (); i++) { Grob *r = Note_column::get_rest (rests[i]); Direction d = get_grob_direction (r); if (d) - ordered_rests[d].push (rests[i]); + ordered_rests[d].push_back (rests[i]); else rests[d]->warning (_ ("can't resolve rest collision: rest direction not set")); } @@ -171,23 +171,23 @@ Rest_collision::calc_positioning_done (SCM smob) common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS); Real diff - = (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP] - - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) / staff_space; + = (ordered_rests[DOWN].back ()->extent (common, Y_AXIS)[UP] + - ordered_rests[UP].back ()->extent (common, Y_AXIS)[DOWN]) / staff_space; if (diff > 0) { int amount_down = (int) ceil (diff / 2); diff -= amount_down; - Note_column::translate_rests (ordered_rests[DOWN].top (), + Note_column::translate_rests (ordered_rests[DOWN].back (), -2 * amount_down); if (diff > 0) - Note_column::translate_rests (ordered_rests[UP].top (), + Note_column::translate_rests (ordered_rests[UP].back (), 2 * int (ceil (diff))); } do { - for (int i = ordered_rests[d].size () -1; i-- > 0;) + for (vsize i = ordered_rests[d].size () -1; i-- > 0;) { Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d]; Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d]; @@ -209,7 +209,7 @@ Rest_collision::calc_positioning_done (SCM smob) Grob *rcol = 0; Direction dir = CENTER; - for (int i = rests.size (); !rcol && i--;) + for (vsize i = rests.size (); !rcol && i--;) if (Note_column::dir (rests[i])) { dir = Note_column::dir (rests[i]); @@ -229,7 +229,7 @@ Rest_collision::calc_positioning_done (SCM smob) Real minimum_dist = robust_scm2double (me->get_property ("minimum-distance"), 1.0) * staff_space; Interval notedim; - for (int i = 0; i < notes.size (); i++) + for (vsize i = 0; i < notes.size (); i++) notedim.unite (notes[i]->extent (common, Y_AXIS)); Real dist diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index d40de198de..ebc156fc95 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -101,12 +101,12 @@ Rhythmic_column_engraver::process_acknowledged () add_spacing_item (note_column_); } - for (int i = 0; i < rheads_.size (); i++) + for (vsize i = 0; i < rheads_.size (); i++) { if (!rheads_[i]->get_parent (X_AXIS)) Note_column::add_head (note_column_, rheads_[i]); } - rheads_.set_size (0); + rheads_.resize (0); } if (note_column_) @@ -133,7 +133,7 @@ Rhythmic_column_engraver::acknowledge_stem (Grob_info i) void Rhythmic_column_engraver::acknowledge_rhythmic_head (Grob_info i) { - rheads_.push (i.grob ()); + rheads_.push_back (i.grob ()); } void diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index b582326786..7b9c5ef282 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -111,15 +111,15 @@ Score_engraver::one_time_step () void Score_engraver::announce_grob (Grob_info info) { - announce_infos_.push (info); + announce_infos_.push_back (info); pscore_->root_system ()->typeset_grob (info.grob ()); - elems_.push (info.grob ()); + elems_.push_back (info.grob ()); } void Score_engraver::typeset_all () { - for (int i = 0; i < elems_.size (); i++) + for (vsize i = 0; i < elems_.size (); i++) { Grob *elem = elems_[i]; diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 85e37a8ac2..ed9e407775 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -45,7 +45,7 @@ Score_performer::play_element (Audio_element *p) void Score_performer::announce_element (Audio_element_info info) { - announce_infos_.push (info); + announce_infos_.push_back (info); } void diff --git a/lily/score-scheme.cc b/lily/score-scheme.cc index dc33d44e64..3cefb8f772 100644 --- a/lily/score-scheme.cc +++ b/lily/score-scheme.cc @@ -47,7 +47,7 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", /* UGR, FIXME, these are default \layout blocks once again. They suck. */ - for (int i = 0; !score_def && i < sc->defs_.size (); i++) + for (vsize i = 0; !score_def && i < sc->defs_.size (); i++) if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T) score_def = sc->defs_[i]; @@ -97,11 +97,11 @@ LY_DEFINE (ly_score_process, "ly:score-process", ? score->header_ : default_header; - for (int i = 0; i < score->defs_.size (); i++) + for (vsize i = 0; i < score->defs_.size (); i++) default_rendering (score->get_music (), score->defs_[i]->self_scm (), default_paper, header, basename, key->self_scm ()); - if (score->defs_.is_empty ()) + if (score->defs_.empty ()) { default_rendering (score->get_music (), default_layout, diff --git a/lily/score.cc b/lily/score.cc index 1545debcfb..9b525ddd23 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -51,7 +51,7 @@ Score::mark_smob (SCM s) Score *sc = (Score *) SCM_CELL_WORD_1 (s); scm_gc_mark (sc->header_); - for (int i = sc->defs_.size (); i--;) + for (vsize i = sc->defs_.size (); i--;) scm_gc_mark (sc->defs_[i]->self_scm ()); return sc->music_; } @@ -81,10 +81,10 @@ Score::Score (Score const &s) else music_ = SCM_EOL; - for (int i = 0, n = s.defs_.size (); i < n; i++) + for (vsize i = 0, n = s.defs_.size (); i < n; i++) { Output_def *copy = s.defs_[i]->clone (); - defs_.push (copy); + defs_.push_back (copy); copy->unprotect (); } header_ = ly_make_anonymous_module (false); @@ -237,5 +237,5 @@ Score::get_music () const void Score::add_output_def (Output_def *def) { - defs_.push (def); + defs_.push_back (def); } diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index 53b50336a5..41555cdbff 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -38,7 +38,7 @@ Script_column_engraver::stop_translation_timestep () { if (scol_) { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) if (Side_position_interface::get_axis (scripts_[i]) == Y_AXIS) Script_column::add_staff_sided (scol_, scripts_[i]); } @@ -54,7 +54,7 @@ Script_column_engraver::acknowledge_side_position (Grob_info inf) if (thing) { if (!Item::is_breakable (thing)) - scripts_.push (thing); + scripts_.push_back (thing); } } diff --git a/lily/script-column.cc b/lily/script-column.cc index 29cf1a53c7..bfd95f999b 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -45,7 +45,7 @@ Script_column::before_line_breaking (SCM smob) Link_array staff_sided; extract_grob_set (me, "scripts", scripts); - for (int i = 0; i < scripts.size (); i++) + for (vsize i = 0; i < scripts.size (); i++) { Grob *sc = scripts[i]; @@ -54,10 +54,10 @@ Script_column::before_line_breaking (SCM smob) */ if (sc->get_property_data (ly_symbol2scm ("X-offset")) != Side_position_interface::x_aligned_side_proc) - staff_sided.push (sc); + staff_sided.push_back (sc); } - for (int i = 0; i < staff_sided.size (); i++) + for (vsize i = 0; i < staff_sided.size (); i++) { Grob *g = staff_sided[i]; Direction d = get_grob_direction (g); diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 44d9de4cac..f0284d85a9 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -34,7 +34,7 @@ struct Script_tuple class Script_engraver : public Engraver { - Array scripts_; + std::vector scripts_; Spanner *slur_; protected: @@ -72,7 +72,7 @@ Script_engraver::try_music (Music *m) Script_tuple t; t.event_ = m; - scripts_.push (t); + scripts_.push_back (t); return true; } return false; @@ -151,7 +151,7 @@ void make_script_from_event (Grob *p, Context *tg, void Script_engraver::process_music () { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Music *music = scripts_[i].event_; @@ -201,7 +201,7 @@ Script_engraver::acknowledge_rhythmic_head (Grob_info info) { if (info.music_cause ()) { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i].script_; @@ -224,7 +224,7 @@ Script_engraver::acknowledge_note_column (Grob_info info) As the note head to put it on is not known now, postpone this decision to Script_interface::calc_direction (). */ - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i].script_; diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index cdf126d3dc..c019fc0430 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -83,7 +83,7 @@ Separating_group_spanner::set_spacing_rods (SCM smob) Real padding = robust_scm2double (me->get_property ("padding"), 0.1); extract_grob_set (me, "elements", elts); - for (int i = elts.size (); + for (vsize i = elts.size (); i-- > 1;) { Item *r = dynamic_cast (elts[i]); diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 6ac3af3fc1..1db11947a3 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -92,7 +92,7 @@ Separating_line_group_engraver::finalize () sep_span_->set_bound (RIGHT, unsmob_grob (ccol)); sep_span_ = 0; - for (int i = 0; i < last_spacings_.note_spacings_.size (); i++) + for (vsize i = 0; i < last_spacings_.note_spacings_.size (); i++) { Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i], ly_symbol2scm ("right-items"), @@ -119,7 +119,7 @@ Separating_line_group_engraver::acknowledge_item (Grob_info i) if (Note_spacing::has_interface (it)) { - current_spacings_.note_spacings_.push (it); + current_spacings_.note_spacings_.push_back (it); return; } diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 37e4ef2ef0..6406a3e0fc 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -39,7 +39,7 @@ Separation_item::conditional_width (Grob *me, Grob *left) Paper_column *pc = item->get_column (); extract_grob_set (me, "conditional-elements", elts); - for (int i = 0; i < elts.size (); i++) + for (vsize i = 0; i < elts.size (); i++) { Item *il = dynamic_cast (elts[i]); if (pc != il->get_column ()) @@ -74,7 +74,7 @@ Separation_item::width (Grob *me) Interval w; extract_grob_set (me, "elements", elts); - for (int i = 0; i < elts.size (); i++) + for (vsize i = 0; i < elts.size (); i++) { Item *il = dynamic_cast (elts[i]); if (pc != il->get_column ()) @@ -123,7 +123,7 @@ Separation_item::extremal_break_aligned_grob (Grob *me, Grob *last_grob = 0; extract_grob_set (me, "elements", elts); - for (int i = elts.size (); i--;) + for (vsize i = elts.size (); i--;) { Grob *break_item = elts[i]; if (!scm_is_symbol (break_item->get_property ("break-align-symbol"))) diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index a035ca45a0..65f2a694a8 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -74,7 +74,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten dim.unite (staff_extents); } - for (int i = 0; i < support.size (); i++) + for (vsize i = 0; i < support.size (); i++) { Grob *e = support[i]; if (e) diff --git a/lily/simple-spacer-scheme.cc b/lily/simple-spacer-scheme.cc index b8a8246ab9..c47993fb6a 100644 --- a/lily/simple-spacer-scheme.cc +++ b/lily/simple-spacer-scheme.cc @@ -60,12 +60,12 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", else spacer.my_solve_linelen (); - Array posns; - posns.push (0.0); - for (int i = 0; i < spacer.springs_.size (); i++) + std::vector posns; + posns.push_back (0.0); + for (vsize i = 0; i < spacer.springs_.size (); i++) { Real l = spacer.springs_[i].length ((is_ragged) ? 0.0 : spacer.force_); - posns.push (posns.top () + l); + posns.push_back (posns.back () + l); } SCM force_return = SCM_BOOL_F; @@ -74,11 +74,11 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", force_return = scm_from_double (spacer.force_); if (is_ragged - && posns.top () > spacer.line_len_) + && posns.back () > spacer.line_len_) force_return = SCM_BOOL_F; SCM retval = SCM_EOL; - for (int i = posns.size (); i--;) + for (vsize i = posns.size (); i--;) retval = scm_cons (scm_from_double (posns[i]), retval); retval = scm_cons (force_return, retval); diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 6b359f38c0..be700c693c 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -132,7 +132,7 @@ Real Simple_spacer::active_blocking_force () const { Real bf = -infinity_f; - for (int i = 0; i < springs_.size (); i++) + for (vsize i = 0; i < springs_.size (); i++) if (springs_[i].is_active_) bf = max (bf, springs_[i].block_force_); return bf; @@ -151,7 +151,7 @@ Simple_spacer::active_springs_stiffness () const Real max_block_force = -infinity_f; int max_i = -1; - for (int i = 0; i < springs_.size (); i++) + for (vsize i = 0; i < springs_.size (); i++) { if (springs_[i].block_force_ > max_block_force) { @@ -169,7 +169,7 @@ void Simple_spacer::set_active_states () { /* float comparison is safe, since force is only copied. */ - for (int i = 0; i < springs_.size (); i++) + for (vsize i = 0; i < springs_.size (); i++) if (springs_[i].is_active_ && springs_[i].block_force_ >= force_) { @@ -182,7 +182,7 @@ Real Simple_spacer::configuration_length () const { Real l = 0.; - for (int i = 0; i < springs_.size (); i++) + for (vsize i = 0; i < springs_.size (); i++) l += springs_[i].length (force_); return l; @@ -292,11 +292,11 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) We used to have a penalty for compression, no matter what, but that fucked up wtk1-fugue2 (taking 3 full pages.) */ - positions->config_.push (spacer_->indent_); - for (int i = 0; i < spacer_->springs_.size (); i++) + positions->config_.push_back (spacer_->indent_); + for (vsize i = 0; i < spacer_->springs_.size (); i++) { Real l = spacer_->springs_[i].length ((ragged) ? 0.0 : spacer_->force_); - positions->config_.push (positions->config_.top () + l); + positions->config_.push_back (positions->config_.back () + l); /* we have l>= 0 here, up to rounding errors */ @@ -309,7 +309,7 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) if (ragged) { positions->satisfies_constraints_ - = positions->config_.top () < spacer_->line_len_; + = positions->config_.back () < spacer_->line_len_; } else positions->satisfies_constraints_ = spacer_->is_active (); @@ -365,7 +365,7 @@ Simple_spacer::add_spring (Real ideal, Real inverse_hooke) active_count_++; } - springs_.push (desc); + springs_.push_back (desc); } static int @@ -381,14 +381,14 @@ Simple_spacer_wrapper::add_columns (Link_array const &icols) Link_array cols (icols); cols.clear (); - for (int i = 0; i < icols.size (); i++) + for (vsize i = 0; i < icols.size (); i++) if (scm_is_pair (icols[i]->get_object ("between-cols"))) - loose_cols_.push (icols[i]); + loose_cols_.push_back (icols[i]); else - cols.push (icols[i]); + cols.push_back (icols[i]); spaced_cols_ = cols; - for (int i = 0; i < cols.size () - 1; i++) + for (vsize i = 0; i < cols.size () - 1; i++) { Spring_smob *spring = 0; @@ -412,7 +412,7 @@ Simple_spacer_wrapper::add_columns (Link_array const &icols) spacer_->add_spring (ideal, inverse_hooke); } - for (int i = 0; i < cols.size () - 1; i++) + for (vsize i = 0; i < cols.size () - 1; i++) { for (SCM s = Spaceable_grob::get_minimum_distances (cols[i]); scm_is_pair (s); s = scm_cdr (s)) diff --git a/lily/skyline.cc b/lily/skyline.cc index 2ed56cd7e9..09ff410cda 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -29,7 +29,7 @@ skyline[...].width_ forms a partition of the real interval, where the segments are adjacent, and ascending. Hence we have - skyline.top ().width_[RIGHT] = inf + skyline.back ().width_[RIGHT] = inf skyline[0].width_[LEFT] = -inf */ @@ -42,7 +42,7 @@ const Real EPS = 1e-12; binsearch. */ void -insert_extent_into_skyline (Array *line, Box b, Axis line_axis, +insert_extent_into_skyline (std::vector *line, Box b, Axis line_axis, Direction d) { Interval extent = b[line_axis]; @@ -54,7 +54,7 @@ insert_extent_into_skyline (Array *line, Box b, Axis line_axis, /* Intersect each segment of LINE with EXTENT, and if non-empty, insert relevant segments. */ - for (int i = line->size (); i--;) + for (vsize i = line->size (); i--;) { Interval w = line->elem (i).width_; w.intersect (extent); @@ -83,11 +83,11 @@ insert_extent_into_skyline (Array *line, Box b, Axis line_axis, } void -merge_skyline (Array *a1, - Array const &a2, +merge_skyline (std::vector *a1, + std::vector const &a2, Direction dir) { - for (int i = 0; i < a2.size (); i++) + for (vsize i = 0; i < a2.size (); i++) { Box b; b[X_AXIS] = a2[i].width_; @@ -98,10 +98,10 @@ merge_skyline (Array *a1, } } -Array +std::vector empty_skyline (Direction d) { - Array skyline; + std::vector skyline; Interval i; i.set_empty (); @@ -109,15 +109,15 @@ empty_skyline (Direction d) Skyline_entry e; e.width_ = i; e.height_ = -d * infinity_f; - skyline.push (e); + skyline.push_back (e); return skyline; } -Array -extents_to_skyline (Array const &extents, Axis a, Direction d) +std::vector +extents_to_skyline (std::vector const &extents, Axis a, Direction d) { - Array skyline = empty_skyline (d); + std::vector skyline = empty_skyline (d); /* This makes a cubic algorithm (array insertion is O (n), @@ -126,7 +126,7 @@ extents_to_skyline (Array const &extents, Axis a, Direction d) We could do a lot better (n log (n), using a balanced tree) but that seems overkill for now. */ - for (int j = extents.size (); j--;) + for (vsize j = extents.size (); j--;) insert_extent_into_skyline (&skyline, extents[j], a, d); return skyline; @@ -139,8 +139,8 @@ extents_to_skyline (Array const &extents, Axis a, Direction d) This is an O (n) algorithm. */ Real -skyline_meshing_distance (Array const &buildings, - Array const &clouds) +skyline_meshing_distance (std::vector const &buildings, + std::vector const &clouds) { int i = buildings.size () -1; int j = clouds.size () -1; @@ -176,14 +176,14 @@ Skyline_entry::Skyline_entry (Interval i, Real r) } void -heighten_skyline (Array *buildings, Real ground) +heighten_skyline (std::vector *buildings, Real ground) { - for (int i = 0; i < buildings->size (); i++) + for (vsize i = 0; i < buildings->size (); i++) buildings->elem_ref (i).height_ += ground; } Real -skyline_height (Array const &buildings, +skyline_height (std::vector const &buildings, Real airplane, Direction sky_dir) { @@ -192,7 +192,7 @@ skyline_height (Array const &buildings, /* Ugh! linear, should be O(log n). */ - for (int i = 0; i < buildings.size (); i++) + for (vsize i = 0; i < buildings.size (); i++) if (buildings[i].width_.contains (airplane)) h = sky_dir * max (sky_dir * h, sky_dir * buildings[i].height_); diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index 1fc83bb8b7..f67b00469a 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -25,10 +25,10 @@ avoid_staff_line (Slur_score_state const &state, Bezier bez) { Offset horiz (1, 0); - Array ts = bez.solve_derivative (horiz); + std::vector ts = bez.solve_derivative (horiz); /* TODO: handle case of broken slur. */ - if (!ts.is_empty () + if (!ts.empty () && (state.extremes_[LEFT].staff_ == state.extremes_[RIGHT].staff_) && state.extremes_[LEFT].staff_ && state.extremes_[RIGHT].staff_) { @@ -64,7 +64,7 @@ avoid_staff_line (Slur_score_state const &state, Real fit_factor (Offset dz_unit, Offset dz_perp, - Bezier curve, Direction d, Array const &avoid) + Bezier curve, Direction d, std::vector const &avoid) { Real fit_factor = 0.0; Offset x0 = curve.control_[0]; @@ -76,7 +76,7 @@ fit_factor (Offset dz_unit, Offset dz_perp, curve_xext.add_point (curve.control_[0][X_AXIS]); curve_xext.add_point (curve.control_[3][X_AXIS]); - for (int i = 0; i < avoid.size (); i++) + for (vsize i = 0; i < avoid.size (); i++) { Offset z = (avoid[i] - x0); Offset p (dot_product (z, dz_unit), @@ -98,7 +98,7 @@ fit_factor (Offset dz_unit, Offset dz_perp, void Slur_configuration::generate_curve (Slur_score_state const &state, Real r_0, Real h_inf, - Array const &avoid) + std::vector const &avoid) { Offset dz = attachment_[RIGHT]- attachment_[LEFT];; Offset dz_unit = dz; @@ -180,8 +180,8 @@ Slur_configuration::score_encompass (Slur_score_state const &state) Distances for heads that are between slur and line between attachment points. */ - Array convex_head_distances; - for (int j = 0; j < state.encompass_infos_.size (); j++) + std::vector convex_head_distances; + for (vsize j = 0; j < state.encompass_infos_.size (); j++) { Real x = state.encompass_infos_[j].x_; @@ -200,7 +200,7 @@ Slur_configuration::score_encompass (Slur_score_state const &state) if (state.dir_ * head_dy < 0) { demerit += state.parameters_.head_encompass_penalty_; - convex_head_distances.push (0.0); + convex_head_distances.push_back (0.0); } else { @@ -225,7 +225,7 @@ Slur_configuration::score_encompass (Slur_score_state const &state) = state.dir_ * max (state.dir_ * state.encompass_infos_[j].get_point (state.dir_), state.dir_ * line_y); Real d = fabs (closest - y); - convex_head_distances.push (d); + convex_head_distances.push_back (d); } } @@ -258,7 +258,7 @@ Slur_configuration::score_encompass (Slur_score_state const &state) { Real avg_distance = 0.0; Real min_dist = infinity_f; - for (int j = 0; j < convex_head_distances.size (); j++) + for (vsize j = 0; j < convex_head_distances.size (); j++) { min_dist = min (min_dist, convex_head_distances[j]); avg_distance += convex_head_distances[j]; @@ -302,7 +302,7 @@ void Slur_configuration::score_extra_encompass (Slur_score_state const &state) { Real demerit = 0.0; - for (int j = 0; j < state.extra_encompass_infos_.size (); j++) + for (vsize j = 0; j < state.extra_encompass_infos_.size (); j++) { Drul_array attachment = attachment_; Extra_collision_info const &info (state.extra_encompass_infos_[j]); diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 1b8f6d153b..9fee28767a 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -86,17 +86,16 @@ void Slur_engraver::acknowledge_note_column (Grob_info info) { Grob *e = info.grob (); - for (int i = slurs_.size (); i--;) + for (vsize i = slurs_.size (); i--;) Slur::add_column (slurs_[i], e); - for (int i = end_slurs_.size (); i--;) + for (vsize i = end_slurs_.size (); i--;) Slur::add_column (end_slurs_[i], e); } void Slur_engraver::acknowledge_extra_object (Grob_info info) { - if (slurs_.is_empty () - && end_slurs_.is_empty ()) + if (slurs_.empty () && end_slurs_.empty ()) return ; Grob *e = info.grob (); @@ -104,9 +103,9 @@ Slur_engraver::acknowledge_extra_object (Grob_info info) if (Tie::has_interface (e) || avoid == ly_symbol2scm ("inside")) { - for (int i = slurs_.size (); i--;) + for (vsize i = slurs_.size (); i--;) Slur::add_extra_encompass (slurs_[i], e); - for (int i = end_slurs_.size (); i--;) + for (vsize i = end_slurs_.size (); i--;) Slur::add_extra_encompass (end_slurs_[i], e); } else if (avoid == ly_symbol2scm ("outside") @@ -189,7 +188,7 @@ Slur_engraver::process_music () slurs_.clear (); } - if (events_[START] && slurs_.is_empty ()) + if (events_[START] && slurs_.empty ()) { Music *ev = events_[START]; @@ -200,14 +199,14 @@ Slur_engraver::process_music () if (updown && !double_slurs) set_grob_direction (slur, updown); - slurs_.push (slur); + slurs_.push_back (slur); if (double_slurs) { set_grob_direction (slur, DOWN); slur = make_spanner ("Slur", events_[START]->self_scm ()); set_grob_direction (slur, UP); - slurs_.push (slur); + slurs_.push_back (slur); } } set_melisma (slurs_.size ()); diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 88d528e34f..19ce9ee47c 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -285,7 +285,7 @@ Slur_score_state::fill (Grob *me) columns_ = internal_extract_grob_array (me, ly_symbol2scm ("note-columns")); - if (columns_.is_empty ()) + if (columns_.empty ()) { me->suicide (); return; @@ -336,8 +336,8 @@ Slur_score_state::fill (Grob *me) = get_y_attachment_range (); configurations_ = enumerate_attachments (end_ys); - for (int i = 0; i < columns_.size (); i++) - encompass_infos_.push (get_encompass_info (columns_[i])); + for (vsize i = 0; i < columns_.size (); i++) + encompass_infos_.push_back (get_encompass_info (columns_[i])); extra_encompass_infos_ = get_extra_encompass_infos (); valid_ = true; @@ -417,9 +417,9 @@ Slur_score_state::get_best_curve () else #endif { - for (int i = 0; i < configurations_.size (); i++) + for (vsize i = 0; i < configurations_.size (); i++) configurations_[i]->score (*this); - for (int i = 0; i < configurations_.size (); i++) + for (vsize i = 0; i < configurations_.size (); i++) { if (configurations_[i]->score_ < opt) { @@ -457,7 +457,7 @@ Slur_score_state::get_closest_index (SCM inspect_quants) const int opt_idx = -1; Real mindist = 1e6; - for (int i = 0; i < configurations_.size (); i++) + for (vsize i = 0; i < configurations_.size (); i++) { Real d = fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ins[LEFT]) + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ins[RIGHT]); @@ -567,7 +567,7 @@ Slur_score_state::get_base_attachments () const x = extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS)[d]; else x = slur_->get_broken_left_end_align (); - Grob *col = (d == LEFT) ? columns_[0] : columns_.top (); + Grob *col = (d == LEFT) ? columns_[0] : columns_.back (); if (extremes_[-d].bound_ != col) { @@ -631,13 +631,13 @@ Slur_score_state::move_away_from_staffline (Real y, return y; } -Array +std::vector Slur_score_state::generate_avoid_offsets () const { - Array avoid; + std::vector avoid; Link_array encompasses = columns_; - for (int i = 0; i < encompasses.size (); i++) + for (vsize i = 0; i < encompasses.size (); i++) { if (extremes_[LEFT].note_column_ == encompasses[i] || extremes_[RIGHT].note_column_ == encompasses[i]) @@ -646,11 +646,11 @@ Slur_score_state::generate_avoid_offsets () const Encompass_info inf (get_encompass_info (encompasses[i])); Real y = dir_ * (max (dir_ * inf.head_, dir_ * inf.stem_)); - avoid.push (Offset (inf.x_, y + dir_ * parameters_.free_head_distance_)); + avoid.push_back (Offset (inf.x_, y + dir_ * parameters_.free_head_distance_)); } extract_grob_set (slur_, "encompass-objects", extra_encompasses); - for (int i = 0; i < extra_encompasses.size (); i++) + for (vsize i = 0; i < extra_encompasses.size (); i++) { if (Slur::has_interface (extra_encompasses[i])) { @@ -662,7 +662,7 @@ Slur_score_state::generate_avoid_offsets () const small_slur->relative_coordinate (common_[Y_AXIS], Y_AXIS)); z[Y_AXIS] += dir_ * parameters_.free_slur_distance_; - avoid.push (z); + avoid.push_back (z); } else if (extra_encompasses[i]->get_property ("avoid-slur") == ly_symbol2scm ("inside")) { @@ -672,7 +672,7 @@ Slur_score_state::generate_avoid_offsets () const if (!xe.is_empty () && !ye.is_empty ()) - avoid.push (Offset (xe.center(), ye[dir_])); + avoid.push_back (Offset (xe.center(), ye[dir_])); } } return avoid; @@ -684,8 +684,8 @@ Slur_score_state::generate_curves () const Real r_0 = robust_scm2double (slur_->get_property ("ratio"), 0.33); Real h_inf = staff_space_ * scm_to_double (slur_->get_property ("height-limit")); - Array avoid = generate_avoid_offsets (); - for (int i = 0; i < configurations_.size (); i++) + std::vector avoid = generate_avoid_offsets (); + for (vsize i = 0; i < configurations_.size (); i++) configurations_[i]->generate_curve (*this, r_0, h_inf, avoid); } @@ -768,7 +768,7 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const s.attachment_ = os; s.index_ = scores.size (); - scores.push (new Slur_configuration (s)); + scores.push_back (new Slur_configuration (s)); os[RIGHT][Y_AXIS] += dir_ * staff_space_ / 2; } @@ -780,12 +780,12 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const return scores; } -Array +std::vector Slur_score_state::get_extra_encompass_infos () const { extract_grob_set (slur_, "encompass-objects", encompasses); - Array collision_infos; - for (int i = encompasses.size (); i--;) + std::vector collision_infos; + for (vsize i = encompasses.size (); i--;) { if (Slur::has_interface (encompasses[i])) { @@ -820,7 +820,7 @@ Slur_score_state::get_extra_encompass_infos () const xext, yext, parameters_.extra_object_collision_penalty_); - collision_infos.push (info); + collision_infos.push_back (info); } } else @@ -868,7 +868,7 @@ Slur_score_state::get_extra_encompass_infos () const ye.widen (thickness_ * 0.5); xe.widen (thickness_ * 1.0); Extra_collision_info info (g, xp, xe, ye, penalty); - collision_infos.push (info); + collision_infos.push_back (info); } } diff --git a/lily/slur.cc b/lily/slur.cc index d40104b1ad..7c015019ff 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -38,14 +38,14 @@ Slur::calc_direction (SCM smob) Grob *me = unsmob_grob (smob); extract_grob_set (me, "note-columns", encompasses); - if (encompasses.is_empty ()) + if (encompasses.empty ()) { me->suicide (); return SCM_BOOL_F; } Direction d = DOWN; - for (int i = 0; i < encompasses.size (); i++) + for (vsize i = 0; i < encompasses.size (); i++) { if (Note_column::dir (encompasses[i]) < 0) { @@ -64,7 +64,8 @@ Slur::height (SCM smob) // FIXME uncached Stencil *m = me->get_stencil (); - return m ? ly_interval2scm (m->extent (Y_AXIS)) : ly_interval2scm (Interval ()); + return m ? ly_interval2scm (m->extent (Y_AXIS)) + : ly_interval2scm (Interval ()); } /* @@ -76,7 +77,7 @@ Slur::print (SCM smob) { Grob *me = unsmob_grob (smob); extract_grob_set (me, "note-columns", encompasses); - if (encompasses.is_empty ()) + if (encompasses.empty ()) { me->suicide (); return SCM_EOL; diff --git a/lily/source-file.cc b/lily/source-file.cc index 9d4a3db37a..d4a3681da2 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -37,11 +37,16 @@ Source_file::load_stdin () length_ = 0; int c; - Array chs; // ugh. +#if STD_VECTOR + std::vector &chs = *new std::vector; // ugh. ugh. +#else + std::vector chs; // ugh. +#endif + while ((c = fgetc (stdin)) != EOF) - chs.push (c); + chs.push_back (c); - chs.push (0); + chs.push_back (0); length_ = chs.size (); contents_str0_ = chs.remove_array (); } @@ -90,7 +95,7 @@ Source_file::Source_file (std::string filename, std::string data) for (int i = 0; i < length_; i++) if (contents_str0_[i] == '\n') - newline_locations_.push (contents_str0_ + i); + newline_locations_.push_back (contents_str0_ + i); } Source_file::Source_file (std::string filename_string) @@ -113,7 +118,7 @@ Source_file::Source_file (std::string filename_string) for (int i = 0; i < length_; i++) if (contents_str0_[i] == '\n') - newline_locations_.push (contents_str0_ + i); + newline_locations_.push_back (contents_str0_ + i); } void diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 616cabe7d0..8b54857b1d 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -64,7 +64,7 @@ is_loose_column (Grob *l, Grob *c, Grob *r, Spacing_options const *options) such a borderline case.) */ - if (lns.is_empty () || rns.is_empty ()) + if (lns.empty () || rns.empty ()) return false; Item *l_neighbor = dynamic_cast (lns[0]); @@ -98,13 +98,13 @@ is_loose_column (Grob *l, Grob *c, Grob *r, Spacing_options const *options) in any case, we don't want to move bar lines. */ extract_grob_set (c, "elements", elts); - for (int i = elts.size (); i--;) + for (vsize i = elts.size (); i--;) { Grob *g = elts[i]; if (g && Break_align_interface::has_interface (g)) { extract_grob_set (g, "elements", gelts); - for (int j = gelts.size (); j--;) + for (vsize j = gelts.size (); j--;) { Grob *h = gelts[j]; @@ -131,7 +131,7 @@ Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, { Link_array newcols; - for (int i = 0; i < cols->size (); i++) + for (vsize i = 0; i < cols->size (); i++) { Grob *c = cols->elem (i); @@ -143,8 +143,8 @@ Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, extract_grob_set (c, "right-neighbors", rns_arr); extract_grob_set (c, "left-neighbors", lns_arr); - SCM lns = lns_arr.size () ? lns_arr.top ()->self_scm () : SCM_BOOL_F; - SCM rns = rns_arr.size () ? rns_arr.top ()->self_scm () : SCM_BOOL_F; + SCM lns = lns_arr.size () ? lns_arr.back ()->self_scm () : SCM_BOOL_F; + SCM rns = rns_arr.size () ? rns_arr.back ()->self_scm () : SCM_BOOL_F; /* Either object can be non existent, if the score ends @@ -171,7 +171,7 @@ Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, Item *rc = dynamic_cast (d == LEFT ? c : next_door[RIGHT]); extract_grob_set (lc, "spacing-wishes", wishes); - for (int k = wishes.size (); k--;) + for (vsize k = wishes.size (); k--;) { Grob *sp = wishes[k]; if (Note_spacing::left_column (sp) != lc @@ -218,7 +218,7 @@ Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, r.add_to_cols (); } else - newcols.push (c); + newcols.push_back (c); } *cols = newcols; @@ -230,14 +230,14 @@ Spacing_spanner::prune_loose_columns (Grob *me, Link_array *cols, void Spacing_spanner::set_explicit_neighbor_columns (Link_array const &cols) { - for (int i = 0; i < cols.size (); i++) + for (vsize i = 0; i < cols.size (); i++) { SCM right_neighbors = Grob_array::make_array (); Grob_array *rn_arr = unsmob_grob_array (right_neighbors); int min_rank = 100000; // inf. extract_grob_set (cols[i], "spacing-wishes", wishes); - for (int k = wishes.size (); k--;) + for (vsize k = wishes.size (); k--;) { Item *wish = dynamic_cast (wishes[k]); @@ -272,7 +272,7 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array const &cols) extract_grob_set (rc, "left-neighbors", lns_arr); if (lns_arr.size ()) { - Item *it = dynamic_cast (lns_arr.top ()); + Item *it = dynamic_cast (lns_arr.back ()); maxrank = Paper_column::get_rank (it->get_column ()); } @@ -302,7 +302,7 @@ Spacing_spanner::set_explicit_neighbor_columns (Link_array const &cols) void Spacing_spanner::set_implicit_neighbor_columns (Link_array const &cols) { - for (int i = 0; i < cols.size (); i++) + for (vsize i = 0; i < cols.size (); i++) { Item *it = dynamic_cast (cols[i]); if (!Item::is_breakable (it) && !Paper_column::is_musical (it)) @@ -314,7 +314,7 @@ Spacing_spanner::set_implicit_neighbor_columns (Link_array const &cols) sloppy with typing left/right-neighbors should take list, but paper-column found instead. */ extract_grob_set (cols[i], "left-neighbors", lns); - if (lns.is_empty () && i) + if (lns.empty () && i) { SCM ga_scm = Grob_array::make_array (); Grob_array *ga = unsmob_grob_array (ga_scm); @@ -322,7 +322,7 @@ Spacing_spanner::set_implicit_neighbor_columns (Link_array const &cols) cols[i]->set_object ("left-neighbors", ga_scm); } extract_grob_set (cols[i], "right-neighbors", rns); - if (rns.is_empty () && i < cols.size () - 1) + if (rns.empty () && i < cols.size () - 1) { SCM ga_scm = Grob_array::make_array (); Grob_array *ga = unsmob_grob_array (ga_scm); diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc index 4e9b9c0675..4b09a917d3 100644 --- a/lily/spacing-engraver.cc +++ b/lily/spacing-engraver.cc @@ -42,8 +42,8 @@ struct Rhythmic_tuple class Spacing_engraver : public Engraver { PQueue playing_durations_; - Array now_durations_; - Array stopped_durations_; + std::vector now_durations_; + std::vector stopped_durations_; Moment now_; Spanner *spacing_; @@ -129,7 +129,7 @@ Spacing_engraver::acknowledge_rhythmic_head (Grob_info i) { Moment len = r->get_length (); Rhythmic_tuple t (i, now_mom () + len); - now_durations_.push (t); + now_durations_.push_back (t); } } } @@ -150,7 +150,7 @@ Spacing_engraver::stop_translation_timestep () Moment shortest_playing; shortest_playing.set_infinite (1); - for (int i = 0; i < playing_durations_.size (); i++) + for (vsize i = 0; i < playing_durations_.size (); i++) { Music *mus = playing_durations_[i].info_.music_cause (); if (mus) @@ -162,7 +162,7 @@ Spacing_engraver::stop_translation_timestep () Moment starter; starter.set_infinite (1); - for (int i = 0; i < now_durations_.size (); i++) + for (vsize i = 0; i < now_durations_.size (); i++) { Moment m = now_durations_[i].info_.music_cause ()->get_length (); if (m.to_bool ()) @@ -191,7 +191,7 @@ Spacing_engraver::start_translation_timestep () while (playing_durations_.size () && playing_durations_.front ().end_ < now_) playing_durations_.delmin (); while (playing_durations_.size () && playing_durations_.front ().end_ == now_) - stopped_durations_.push (playing_durations_.get ()); + stopped_durations_.push_back (playing_durations_.get ()); } ADD_ACKNOWLEDGER (Spacing_engraver, staff_spacing); diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index 2cfb4dc79e..9caba57552 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -57,10 +57,10 @@ set_loose_columns (System *which, Column_x_positions const *posns) if (!left->get_system ()) left = left->find_prebroken_piece (RIGHT); - clique.push (left); + clique.push_back (left); } - clique.push (loose); + clique.push_back (loose); divide_over++; loose = right = re->get_column (); @@ -69,19 +69,19 @@ set_loose_columns (System *which, Column_x_positions const *posns) if (!right->get_system ()) right = right->find_prebroken_piece (LEFT); - clique.push (right); + clique.push_back (right); Grob *common = right->common_refpoint (left, X_AXIS); - Item *finished_right_column = clique.top (); + Item *finished_right_column = clique.back (); - for (int j = clique.size () - 2; j > 0; j--) + for (vsize j = clique.size () - 2; j > 0; j--) { int count = 0; Real total_space = 0.0; Real total_fixed = 0.0; extract_grob_set (col, "spacing-wishes", wishes); - for (int i = 0; i < wishes.size (); i++) + for (vsize i = 0; i < wishes.size (); i++) { Grob *spacing = wishes[i]; Real space = 0.0; diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index ec4907be63..2ac4caf13e 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -91,13 +91,13 @@ Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) /* ascending in duration */ - Array durations; - Array counts; + std::vector durations; + std::vector counts; Rational shortest_in_measure; shortest_in_measure.set_infinite (1); - for (int i = 0; i < cols.size (); i++) + for (vsize i = 0; i < cols.size (); i++) { if (Paper_column::is_musical (cols[i])) { @@ -117,7 +117,7 @@ Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) else if (!shortest_in_measure.is_infinity () && Item::is_breakable (cols[i])) { - int j = 0; + vsize j = 0; for (; j < durations.size (); j++) { if (durations[j] > shortest_in_measure) @@ -135,8 +135,8 @@ Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) if (durations.size () == j) { - durations.push (shortest_in_measure); - counts.push (1); + durations.push_back (shortest_in_measure); + counts.push_back (1); } shortest_in_measure.set_infinite (1); @@ -145,7 +145,7 @@ Spacing_spanner::find_shortest (Grob *me, Link_array const &cols) int max_idx = -1; int max_count = 0; - for (int i = durations.size (); i--;) + for (vsize i = durations.size (); i--;) { if (counts[i] >= max_count) { @@ -230,7 +230,7 @@ Spacing_spanner::generate_springs (Grob *me, { Paper_column *next = 0; Paper_column *next_next = 0; - for (int i = cols.size (); i--;) + for (vsize i = cols.size (); i--;) { Paper_column *col = dynamic_cast (cols[i]); if (next) @@ -272,7 +272,7 @@ Spacing_spanner::musical_column_spacing (Grob *me, happens after the current note (this is set in the grob property SPACING-SEQUENCE. */ - for (int i = 0; i < neighbors.size (); i++) + for (vsize i = 0; i < neighbors.size (); i++) { Grob *wish = neighbors[i]; @@ -386,7 +386,7 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, { extract_grob_set (l, "spacing-wishes", wishes); - for (int i = 0; i < wishes.size (); i++) + for (vsize i = 0; i < wishes.size (); i++) { Item *spacing_grob = dynamic_cast (wishes[i]); diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index 969885a738..998d2693a2 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -42,7 +42,7 @@ void Span_arpeggio_engraver::acknowledge_arpeggio (Grob_info info) { if (info.origin_contexts (this).size ()) // huh? what's this test for? - arpeggios_.push (info.grob ()); + arpeggios_.push_back (info.grob ()); } void @@ -69,15 +69,15 @@ Span_arpeggio_engraver::stop_translation_timestep () we do this very late, to make sure we also catch `extra' side-pos support like accidentals. */ - for (int j = 0; j < arpeggios_.size (); j++) + for (vsize j = 0; j < arpeggios_.size (); j++) { extract_grob_set (arpeggios_[j], "stems", stems); - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("stems"), stems[i]); extract_grob_set (arpeggios_[j], "side-support-elements", sses); - for (int i = sses.size (); i--;) + for (vsize i = sses.size (); i--;) Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("side-support-elements"), sses[i]); diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 7ec59d3895..158663a979 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -43,7 +43,7 @@ Span_bar_engraver::acknowledge_bar_line (Grob_info i) if (depth && Bar_line::has_interface (i.grob ())) { Item *it = dynamic_cast (i.grob ()); - bars_.push (it); + bars_.push_back (it); if (bars_.size () >= 2 && !spanbar_) { @@ -59,7 +59,7 @@ Span_bar_engraver::stop_translation_timestep () { if (spanbar_) { - for (int i = 0; i < bars_.size (); i++) + for (vsize i = 0; i < bars_.size (); i++) Span_bar::add_bar (spanbar_, bars_[i]); SCM vissym = ly_symbol2scm ("break-visibility"); @@ -69,7 +69,7 @@ Span_bar_engraver::stop_translation_timestep () spanbar_ = 0; } - bars_.set_size (0); + bars_.resize (0); } #include "translator.icc" diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 2149f2ddfc..6290277358 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -56,16 +56,16 @@ Span_bar::print (SCM smobbed_me) std::string glyph_string = ly_scm2string (glyph); /* compose span_bar_mol */ - Array extents; + std::vector extents; Grob *model_bar = 0; - for (int i = elements.size (); i--;) + for (vsize i = elements.size (); i--;) { Grob *bar = elements[i]; Interval ext = bar->extent (refp, Y_AXIS); if (ext.is_empty ()) continue; - extents.push (ext); + extents.push_back (ext); model_bar = bar; } @@ -75,7 +75,7 @@ Span_bar::print (SCM smobbed_me) extents.sort (&Interval::left_comparison); Stencil span_bar; - for (int i = 1; i < extents.size (); i++) + for (vsize i = 1; i < extents.size (); i++) { Interval prev_extent = extents[i - 1]; Interval ext = extents[i]; @@ -132,7 +132,7 @@ Span_bar::before_line_breaking (SCM smob) { Grob *me = unsmob_grob (smob); extract_grob_set (me, "elements", elements); - if (elements.is_empty ()) + if (elements.empty ()) me->suicide (); return SCM_UNSPECIFIED; @@ -167,7 +167,7 @@ Span_bar::calc_glyph_name (SCM smob) Grob *me = unsmob_grob (smob); extract_grob_set (me, "elements", elements); SCM gl = SCM_EOL; - for (int i = elements.size (); + for (vsize i = elements.size (); i-- && !scm_is_string (gl);) gl = elements[i]->get_property ("glyph-name"); diff --git a/lily/span-dynamic-performer.cc b/lily/span-dynamic-performer.cc index 03ed5f1f40..111f9a9442 100644 --- a/lily/span-dynamic-performer.cc +++ b/lily/span-dynamic-performer.cc @@ -41,8 +41,8 @@ private: Real last_volume_; Music *span_start_event_; Drul_array span_events_; - Array dynamic_tuples_; - Array finished_dynamic_tuples_; + std::vector dynamic_tuples_; + std::vector finished_dynamic_tuples_; Direction dir_; Direction finished_dir_; }; @@ -74,7 +74,7 @@ Span_dynamic_performer::process_music () : span_events_[STOP]); announce_element (info); Audio_dynamic_tuple a = { audio_, now_mom () }; - dynamic_tuples_.push (a); + dynamic_tuples_.push_back (a); } if (span_events_[STOP]) @@ -101,11 +101,11 @@ Span_dynamic_performer::process_music () dynamic_tuples_.clear (); Audio_dynamic_tuple a = { audio_, now_mom () }; - dynamic_tuples_.push (a); + dynamic_tuples_.push_back (a); } if (span_events_[STOP]) - finished_dynamic_tuples_.top ().audio_->volume_ = last_volume_; + finished_dynamic_tuples_.back ().audio_->volume_ = last_volume_; if (span_events_[START]) dynamic_tuples_[0].audio_->volume_ = last_volume_; @@ -120,7 +120,7 @@ Span_dynamic_performer::stop_translation_timestep () if (finished_dynamic_tuples_.size () > 1) { Real start_volume = finished_dynamic_tuples_[0].audio_->volume_; - Real dv = finished_dynamic_tuples_.top ().audio_->volume_ + Real dv = finished_dynamic_tuples_.back ().audio_->volume_ - start_volume; /* urg. @@ -138,12 +138,12 @@ Span_dynamic_performer::stop_translation_timestep () // urg. 20%: about two volume steps dv = (Real)finished_dir_ * 0.2; if (!start_volume) - start_volume = finished_dynamic_tuples_.top - ().audio_->volume_ - dv; + start_volume = finished_dynamic_tuples_.back ().audio_->volume_ + - dv; } Moment start_mom = finished_dynamic_tuples_[0].mom_; - Moment dt = finished_dynamic_tuples_.top ().mom_ - start_mom; - for (int i = 0; i < finished_dynamic_tuples_.size (); i++) + Moment dt = finished_dynamic_tuples_.back ().mom_ - start_mom; + for (vsize i = 0; i < finished_dynamic_tuples_.size (); i++) { Audio_dynamic_tuple *a = &finished_dynamic_tuples_[i]; Real volume = start_volume + dv * (Real) (a->mom_ - start_mom).main_part_ diff --git a/lily/spanner.cc b/lily/spanner.cc index 0e3d0fc559..8a7a1fdc4f 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -73,7 +73,7 @@ Spanner::do_break_processing () assert (span->get_system ()); span->get_system ()->typeset_grob (span); - broken_intos_.push (span); + broken_intos_.push_back (span); } } while ((flip (&d)) != LEFT); @@ -84,9 +84,9 @@ Spanner::do_break_processing () Link_array break_points = root->broken_col_range (left, right); break_points.insert (left, 0); - break_points.push (right); + break_points.push_back (right); - for (int i = 1; i < break_points.size (); i++) + for (vsize i = 1; i < break_points.size (); i++) { Drul_array bounds; bounds[LEFT] = break_points[i - 1]; @@ -120,12 +120,12 @@ Spanner::do_break_processing () else { bounds[LEFT]->get_system ()->typeset_grob (span); - broken_intos_.push (span); + broken_intos_.push_back (span); } } } broken_intos_.sort (Spanner::compare); - for (int i = broken_intos_.size ();i--;) + for (vsize i = broken_intos_.size ();i--;) broken_intos_[i]->break_index_ = i; } @@ -294,7 +294,7 @@ Spanner::derived_mark () const while (flip (&d) != LEFT) ; - for (int i = broken_intos_.size (); i--;) + for (vsize i = broken_intos_.size (); i--;) scm_gc_mark (broken_intos_[i]->self_scm ()); } diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index 994d642c0a..305d3a2468 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -134,7 +134,7 @@ Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob, *compound_space = 0.0; int wish_count = 0; - for (int i = right_items.size (); i--;) + for (vsize i = right_items.size (); i--;) { Grob *g = right_items[i]; @@ -148,7 +148,7 @@ Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob, wish_count ++; extract_grob_set (g, "elements", elts); - for (int j = elts.size (); j--;) + for (vsize j = elts.size (); j--;) { Real space = 0.0; Real fixed = 0.0; @@ -176,7 +176,7 @@ Staff_spacing::get_spacing_params (Grob *me, Real *space, Real *fixed) Item *me_item = dynamic_cast (me); extract_grob_set (me, "left-items", items); - for (int i = items.size (); i--;) + for (vsize i = items.size (); i--;) { Grob *cand = items[i]; if (cand && Separation_item::has_interface (cand)) diff --git a/lily/stanza-number-align-engraver.cc b/lily/stanza-number-align-engraver.cc index 2b98915a21..0a40dcac36 100644 --- a/lily/stanza-number-align-engraver.cc +++ b/lily/stanza-number-align-engraver.cc @@ -37,21 +37,21 @@ void Stanza_number_align_engraver::acknowledge_lyric_syllable (Grob_info gi) { Grob *h = gi.grob (); - lyrics_.push (h); + lyrics_.push_back (h); } void Stanza_number_align_engraver::acknowledge_stanza_number (Grob_info gi) { Grob *h = gi.grob (); - stanza_numbers_.push (h); + stanza_numbers_.push_back (h); } void Stanza_number_align_engraver::stop_translation_timestep () { - for (int i = lyrics_.size (); i--;) - for (int j = stanza_numbers_.size (); j--;) + for (vsize i = lyrics_.size (); i--;) + for (vsize j = stanza_numbers_.size (); j--;) Side_position_interface::add_support (stanza_numbers_[j], lyrics_[i]); stanza_numbers_.clear (); diff --git a/lily/stem.cc b/lily/stem.cc index e572acb652..41f039f623 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -155,7 +155,7 @@ Stem::extremal_heads (Grob *me) Drul_array exthead (0, 0); extract_grob_set (me, "note-heads", heads); - for (int i = heads.size (); i--;) + for (vsize i = heads.size (); i--;) { Grob *n = heads[i]; int p = Staff_symbol_referencer::get_rounded_position (n); @@ -181,18 +181,18 @@ integer_compare (int const &a, int const &b) } /* The positions, in ascending order. */ -Array +std::vector Stem::note_head_positions (Grob *me) { - Array ps; + std::vector ps; extract_grob_set (me, "note-heads", heads); - for (int i = heads.size (); i--;) + for (vsize i = heads.size (); i--;) { Grob *n = heads[i]; int p = Staff_symbol_referencer::get_rounded_position (n); - ps.push (p); + ps.push_back (p); } ps.sort (integer_compare); @@ -233,7 +233,7 @@ Stem::calc_stem_end_position (SCM smob) Real ss = Staff_symbol_referencer::staff_space (me); int durlog = duration_log (me); - Array a; + std::vector a; /* WARNING: IN HALF SPACES */ Real length = robust_scm2double (me->get_property ("length"), 7); @@ -385,13 +385,13 @@ Stem::calc_positioning_done (SCM smob) } Real w = hed->extent (hed, X_AXIS)[dir]; - for (int i = 0; i < heads.size (); i++) + for (vsize i = 0; i < heads.size (); i++) heads[i]->translate_axis (w - heads[i]->extent (heads[i], X_AXIS)[dir], X_AXIS); bool parity = true; Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0])); - for (int i = 1; i < heads.size (); i++) + for (vsize i = 1; i < heads.size (); i++) { Real p = Staff_symbol_referencer::get_position (heads[i]); Real dy = fabs (lastpos- p); @@ -770,7 +770,7 @@ Stem::offset_callback (SCM smob) extract_grob_set (me, "rests", rests); if (rests.size ()) { - Grob *rest = rests.top (); + Grob *rest = rests.back (); r = rest->extent (rest, X_AXIS).center (); } } diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index a8dde07527..6bcdea73b0 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -79,7 +79,7 @@ Bracket_nesting_group::create_grobs (Engraver *engraver, SCM default_type) delimiter_ = make_spanner_from_properties (engraver, type, SCM_EOL, ly_symbol2string (type).c_str ()); - for (int i = 0 ; i < children_.size (); i++) + for (vsize i = 0 ; i < children_.size (); i++) { children_[i]->create_grobs (engraver, default_type); } @@ -89,7 +89,7 @@ void Bracket_nesting_group::add_support (Grob *g) { Side_position_interface::add_support (g, delimiter_); - for (int i = 0 ; i < children_.size (); i++) + for (vsize i = 0 ; i < children_.size (); i++) { children_[i]->add_support (g); } @@ -97,7 +97,7 @@ Bracket_nesting_group::add_support (Grob *g) Bracket_nesting_group::~Bracket_nesting_group () { - for (int i = 0 ; i < children_.size (); i++) + for (vsize i = 0 ; i < children_.size (); i++) delete children_[i]; } @@ -105,7 +105,7 @@ void Bracket_nesting_group::set_bound (Direction d, Grob *g) { delimiter_->set_bound (d, g); - for (int i = 0 ; i < children_.size (); i++) + for (vsize i = 0 ; i < children_.size (); i++) { children_[i]->set_bound (d, g); } @@ -117,7 +117,7 @@ Bracket_nesting_group::set_nesting_support (Grob *parent) if (parent) Side_position_interface::add_support (delimiter_, parent); - for (int i = 0 ; i < children_.size (); i++) + for (vsize i = 0 ; i < children_.size (); i++) { children_[i]->set_nesting_support (delimiter_); } @@ -134,7 +134,7 @@ Bracket_nesting_group::from_list (SCM x) { Bracket_nesting_group *node = new Bracket_nesting_group; node->from_list (entry); - children_.push (node); + children_.push_back (node); } else if (entry == ly_symbol2scm ("SystemStartBrace") || entry == ly_symbol2scm ("SystemStartBracket") @@ -144,7 +144,7 @@ Bracket_nesting_group::from_list (SCM x) symbol_ = entry; else { - children_.push (new Bracket_nesting_staff (0)); + children_.push_back (new Bracket_nesting_staff (0)); } } } @@ -152,7 +152,7 @@ Bracket_nesting_group::from_list (SCM x) bool Bracket_nesting_group::add_staff (Grob *grob) { - for (int i = 0; i < children_.size (); i++) + for (vsize i = 0; i < children_.size (); i++) { if (children_[i]->add_staff (grob)) { @@ -225,7 +225,7 @@ System_start_delimiter_engraver::acknowledge_staff_symbol (Grob_info inf) if (!succ) { - nesting_->children_.push (new Bracket_nesting_staff (0)); + nesting_->children_.push_back (new Bracket_nesting_staff (0)); nesting_->add_staff (staff); } } diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index d0b93a372d..9ad6760580 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -96,7 +96,7 @@ System_start_delimiter::print (SCM smob) Interval ext; int non_empty_count = 0; - for (int i = elts.size (); i--;) + for (vsize i = elts.size (); i--;) { Spanner *sp = dynamic_cast (elts[i]); diff --git a/lily/system.cc b/lily/system.cc index 4da50a8292..8bd370579f 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -66,7 +66,7 @@ int System::spanner_count () const { int k = 0; - for (int i = all_elements_->size (); i--;) + for (vsize i = all_elements_->size (); i--;) if (dynamic_cast (all_elements_->grob (i))) k++; return k; @@ -88,7 +88,7 @@ System::typeset_grob (Grob *elem) void System::derived_mark () const { - if (!all_elements_->is_empty ()) + if (!all_elements_->empty ()) { Grob **ptr = &all_elements_->array_reference ().elem_ref (0); Grob **end = ptr + all_elements_->size (); @@ -108,14 +108,14 @@ System::derived_mark () const static void fixup_refpoints (Link_array const &grobs) { - for (int i = grobs.size (); i--;) + for (vsize i = grobs.size (); i--;) grobs[i]->fixup_refpoint (); } SCM System::get_paper_systems () { - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) { Grob *g = all_elements_->grob (i); if (g->internal_has_interface (ly_symbol2scm ("only-prebreak-interface"))) @@ -139,12 +139,12 @@ System::get_paper_systems () fixups must be done in broken line_of_scores, because new elements are put over there. */ int count = 0; - for (int i = 0; i < broken_intos_.size (); i++) + for (vsize i = 0; i < broken_intos_.size (); i++) { Grob *se = broken_intos_[i]; extract_grob_set (se, "all-elements", all_elts); - for (int j = 0; j < all_elts.size (); j++) + for (vsize j = 0; j < all_elts.size (); j++) { Grob *g = all_elts[j]; g->fixup_refpoint (); @@ -158,7 +158,7 @@ System::get_paper_systems () */ fixup_refpoints (all_elements_->array ()); - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) all_elements_->grob (i)->handle_broken_dependencies (); handle_broken_dependencies (); @@ -200,9 +200,9 @@ System::get_paper_systems () } void -System::break_into_pieces (Array const &breaking) +System::break_into_pieces (std::vector const &breaking) { - for (int i = 0; i < breaking.size (); i++) + for (vsize i = 0; i < breaking.size (); i++) { System *system = dynamic_cast (clone (i)); system->rank_ = i; @@ -211,14 +211,14 @@ System::break_into_pieces (Array const &breaking) pscore_->typeset_system (system); system->set_bound (LEFT, c[0]); - system->set_bound (RIGHT, c.top ()); - for (int j = 0; j < c.size (); j++) + system->set_bound (RIGHT, c.back ()); + for (vsize j = 0; j < c.size (); j++) { c[j]->translate_axis (breaking[i].config_[j], X_AXIS); dynamic_cast (c[j])->system_ = system; } set_loose_columns (system, &breaking[i]); - broken_intos_.push (system); + broken_intos_.push_back (system); } } @@ -236,7 +236,7 @@ System::add_column (Paper_column *p) p->rank_ = ga->size () - ? Paper_column::get_rank (ga->array ().top ()) + 1 + ? Paper_column::get_rank (ga->array ().back ()) + 1 : 0; ga->add (p); @@ -261,7 +261,7 @@ apply_tweaks (Grob *g, bool broken) void System::pre_processing () { - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) all_elements_->grob (i)->discretionary_processing (); if (be_verbose_global) @@ -272,15 +272,15 @@ System::pre_processing () array, and should be processed before the original is potentially killed. */ - for (int i = all_elements_->size (); i--;) + for (vsize i = all_elements_->size (); i--;) all_elements_->grob (i)->handle_prebroken_dependencies (); fixup_refpoints (all_elements_->array ()); - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) apply_tweaks (all_elements_->grob (i), false); - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) { Grob *g = all_elements_->grob (i); (void) g->get_property ("before-line-breaking"); @@ -289,7 +289,7 @@ System::pre_processing () message (_ ("Calculating line breaks...")); progress_indication (" "); - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) { Grob *e = all_elements_->grob (i); (void) e->get_property ("springs-and-rods"); @@ -299,7 +299,7 @@ System::pre_processing () void System::post_processing () { - for (int i = 0; i < all_elements_->size (); i++) + for (vsize i = 0; i < all_elements_->size (); i++) { Grob *g = all_elements_->grob (i); @@ -321,7 +321,7 @@ System::post_processing () all_elts_sorted.default_sort (); all_elts_sorted.uniq (); this->get_stencil (); - for (int i = all_elts_sorted.size (); i--;) + for (vsize i = all_elts_sorted.size (); i--;) { Grob *g = all_elts_sorted[i]; g->get_stencil (); @@ -338,7 +338,7 @@ System::get_paper_system () /* Output stencils in three layers: 0, 1, 2. Default layer: 1. */ for (int i = 0; i < LAYER_COUNT; i++) - for (int j = all_elements_->size (); j--;) + for (vsize j = all_elements_->size (); j--;) { Grob *g = all_elements_->grob (j); Stencil st = g->get_print_stencil (); @@ -386,7 +386,7 @@ System::get_paper_system () Interval staff_refpoints; staff_refpoints.set_empty (); extract_grob_set (this, "spaceable-staves", staves); - for (int i = staves.size (); i--;) + for (vsize i = staves.size (); i--;) { Grob *g = staves[i]; staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS)); @@ -408,7 +408,7 @@ System::broken_col_range (Item const *left, Item const *right) const right = right->get_column (); extract_grob_set (this, "columns", cols); - int i = 0; + vsize i = 0; while (i < cols.size () && cols[i] != left) i++; @@ -421,7 +421,7 @@ System::broken_col_range (Item const *left, Item const *right) const { Paper_column *c = dynamic_cast (cols[i]); if (Item::is_breakable (c) && !c->system_) - ret.push (c); + ret.push_back (c); i++; } @@ -447,7 +447,7 @@ System::columns () const for (int i = 0; i <= last_breakable; i++) { if (Paper_column::is_used (ro_columns[i])) - columns.push (ro_columns[i]); + columns.push_back (ro_columns[i]); } return columns; diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index 3ea9ea5c4e..6da82d3fdd 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -50,12 +50,12 @@ Tab_note_heads_engraver::try_music (Music *m) { if (m->is_mus_type ("note-event")) { - note_events_.push (m); + note_events_.push_back (m); return true; } else if (m->is_mus_type ("string-number-event")) { - tabstring_events_.push (m); + tabstring_events_.push_back (m); return true; } else if (m->is_mus_type ("busy-playing-event")) @@ -68,7 +68,7 @@ void Tab_note_heads_engraver::process_music () { int j = 0; - for (int i = 0; i < note_events_.size (); i++) + for (vsize i = 0; i < note_events_.size (); i++) { SCM stringTunings = get_property ("stringTunings"); int number_of_strings = ((int) ly_length (stringTunings)); @@ -123,7 +123,7 @@ Tab_note_heads_engraver::process_music () d->set_parent (note, Y_AXIS); - dots_.push (d); + dots_.push_back (d); } SCM scm_pitch = event->get_property ("pitch"); @@ -150,7 +150,7 @@ Tab_note_heads_engraver::process_music () note->set_property ("text", text); note->set_property ("staff-position", scm_from_int (pos)); - notes_.push (note); + notes_.push_back (note); } } diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 4052bb9beb..d2eb4055f4 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -37,7 +37,7 @@ Text_engraver::try_music (Music *m) { if (m->is_mus_type ("text-script-event")) { - evs_.push (m); + evs_.push_back (m); return true; } return false; @@ -46,7 +46,7 @@ Text_engraver::try_music (Music *m) void Text_engraver::acknowledge_rhythmic_head (Grob_info inf) { - for (int i = 0; i < texts_.size (); i++) + for (vsize i = 0; i < texts_.size (); i++) { Grob *t = texts_[i]; Side_position_interface::add_support (t, inf.grob ()); @@ -66,14 +66,14 @@ Text_engraver::acknowledge_rhythmic_head (Grob_info inf) void Text_engraver::acknowledge_stem (Grob_info inf) { - for (int i = 0; i < texts_.size (); i++) + for (vsize i = 0; i < texts_.size (); i++) Side_position_interface::add_support (texts_[i], inf.grob ()); } void Text_engraver::acknowledge_stem_tremolo (Grob_info info) { - for (int i = 0; i < texts_.size (); i++) + for (vsize i = 0; i < texts_.size (); i++) Side_position_interface::add_support (texts_[i], info.grob ()); } @@ -82,7 +82,7 @@ Text_engraver::process_acknowledged () { if (texts_.size ()) return; - for (int i = 0; i < evs_.size (); i++) + for (vsize i = 0; i < evs_.size (); i++) { Music *r = evs_[i]; @@ -110,7 +110,7 @@ Text_engraver::process_acknowledged () SCM mark = r->get_property ("text"); text->set_property ("text", mark); - texts_.push (text); + texts_.push_back (text); } } diff --git a/lily/tfm-reader.cc b/lily/tfm-reader.cc index a14a929d3c..10f88a13ae 100644 --- a/lily/tfm-reader.cc +++ b/lily/tfm-reader.cc @@ -25,7 +25,7 @@ Tex_font_metric_reader::Tex_font_metric_reader (std::string name) { for (int i = 0; i < TFM_SIZE; i++) - ascii_to_metric_idx_.push (-1); + ascii_to_metric_idx_.push_back (-1); read_header (); read_params (); @@ -163,7 +163,7 @@ Tex_font_metric_reader::read_char_metrics () Tex_font_char_metric tfm_char = read_char_metric (i); if (tfm_char.exists_) ascii_to_metric_idx_[tfm_char.code_] = char_metrics_.size (); - char_metrics_.push (tfm_char); + char_metrics_.push_back (tfm_char); } } @@ -255,7 +255,7 @@ Tex_font_metric_reader::read_char () #define KERN_FLAG 128 void -Tex_font_metric_reader::read_lig_kern_program (Array *ligatures, Array *kerns) +Tex_font_metric_reader::read_lig_kern_program (std::vector *ligatures, std::vector *kerns) { bool end_b; @@ -277,14 +277,14 @@ Tex_font_metric_reader::read_lig_kern_program (Array *ligatures, A kern_element.kern = get_U32_fix_scaled (); input_.set_pos (old_pos); - kerns->push (kern_element); + kerns->push_back (kern_element); } else { Tfm_ligature ligature_element; ligature_element.character = next_char; ligature_element.ligature = remainder; - ligatures->push (ligature_element); + ligatures->push_back (ligature_element); } } while (!end_b); diff --git a/lily/tfm.cc b/lily/tfm.cc index 82a4fee1ee..136a59aa73 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -77,7 +77,7 @@ Tex_font_metric::find_ascii (int ascii, bool warn) const int Tex_font_metric::count () const { - for (int i = ascii_to_metric_idx_.size (); i--;) + for (vsize i = ascii_to_metric_idx_.size (); i--;) if (ascii_to_metric_idx_[i] != -1) return i + 1; return 0; diff --git a/lily/tie-column.cc b/lily/tie-column.cc index 1ee3d0c03f..a6633aca6e 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -93,7 +93,7 @@ Tie_column::calc_positioning_done (SCM smob) Ties_configuration base = problem.generate_optimal_chord_configuration (); - for (int i = 0; i < base.size(); i++) + for (vsize i = 0; i < base.size(); i++) { Tie::set_control_points (ties[i], problem.common_x_refpoint (), base[i], diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 6382222676..a52a2c73b3 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -49,7 +49,7 @@ class Tie_engraver : public Engraver { Music *event_; Link_array now_heads_; - Array heads_to_tie_; + std::vector heads_to_tie_; Link_array ties_; Spanner *tie_column_; @@ -70,7 +70,7 @@ void Tie_engraver::derived_mark () const { Engraver::derived_mark (); - for (int i = 0; i < heads_to_tie_.size (); i++) + for (vsize i = 0; i < heads_to_tie_.size (); i++) scm_gc_mark (heads_to_tie_[i].tie_definition_); } @@ -100,8 +100,8 @@ void Tie_engraver::acknowledge_note_head (Grob_info i) { Grob *h = i.grob (); - now_heads_.push (h); - for (int i = heads_to_tie_.size (); i--;) + now_heads_.push_back (h); + for (vsize i = heads_to_tie_.size (); i--;) { Grob *th = heads_to_tie_[i].head_; Music *right_mus = unsmob_music (h->get_property ("cause")); @@ -120,7 +120,7 @@ Tie_engraver::acknowledge_note_head (Grob_info i) Tie::set_head (p, LEFT, th); Tie::set_head (p, RIGHT, h); - ties_.push (p); + ties_.push_back (p); heads_to_tie_.del (i); } } @@ -129,7 +129,7 @@ Tie_engraver::acknowledge_note_head (Grob_info i) tie_column_ = make_spanner ("TieColumn", ties_[0]->self_scm ()); if (tie_column_) - for (int i = ties_.size (); i--;) + for (vsize i = ties_.size (); i--;) Tie_column::add_tie (tie_column_, ties_[i]); } @@ -148,7 +148,7 @@ Tie_engraver::stop_translation_timestep () if (!to_boolean (get_property ("tieWaitForNote"))) heads_to_tie_.clear (); - for (int i = 0; i < ties_.size (); i++) + for (vsize i = 0; i < ties_.size (); i++) typeset_tie (ties_[i]); ties_.clear (); @@ -163,9 +163,9 @@ Tie_engraver::stop_translation_timestep () if (!to_boolean (get_property ("tieWaitForNote"))) heads_to_tie_.clear (); - for (int i = 0; i < now_heads_.size (); i++) + for (vsize i = 0; i < now_heads_.size (); i++) { - heads_to_tie_.push (Head_event_tuple (now_heads_[i], event_, + heads_to_tie_.push_back (Head_event_tuple (now_heads_[i], event_, start_definition)); } } diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index 87ea44b36b..b256039498 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -64,10 +64,10 @@ Tie_formatting_problem::set_chord_outline (Link_array bounds, { Real staff_space = Staff_symbol_referencer::staff_space (bounds[0]); - Array boxes; + std::vector boxes; Grob *stem = 0; - for (int i = 0; i < bounds.size (); i++) + for (vsize i = 0; i < bounds.size (); i++) { Grob *head = bounds[i]; if (!Note_head::has_interface (head)) @@ -81,7 +81,7 @@ Tie_formatting_problem::set_chord_outline (Link_array bounds, (p+1) * 0.5 * staff_space); Interval x = head->extent (x_refpoint_, X_AXIS); - boxes.push (Box (x, y)); + boxes.push_back (Box (x, y)); Grob *dots = Rhythmic_head::get_dots (head); if (d == LEFT && dots) @@ -95,7 +95,7 @@ Tie_formatting_problem::set_chord_outline (Link_array bounds, dot_x_.unite (x); y *= staff_space * 0.5; - // boxes.push (Box (x, y)); + // boxes.push_back (Box (x, y)); } } @@ -107,7 +107,7 @@ Tie_formatting_problem::set_chord_outline (Link_array bounds, chord_outlines_[d].elem_ref (0).height_ = x; } - for (int i = 0; i < boxes.size (); i++) + for (vsize i = 0; i < boxes.size (); i++) insert_extent_into_skyline (&chord_outlines_[d] , boxes[i], Y_AXIS, -d); @@ -164,7 +164,7 @@ void Tie_formatting_problem::from_tie (Grob *tie) { Link_array ties; - ties.push (tie); + ties.push_back (tie); from_ties (ties); details_.from_grob (tie); @@ -179,11 +179,11 @@ Tie_formatting_problem::common_x_refpoint () const void Tie_formatting_problem::from_ties (Link_array const &ties) { - if (ties.is_empty ()) + if (ties.empty ()) return; x_refpoint_ = ties[0]; - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) { x_refpoint_ = dynamic_cast (ties[i])->get_bound (LEFT)->common_refpoint (x_refpoint_, X_AXIS); x_refpoint_ = dynamic_cast (ties[i])->get_bound (RIGHT)->common_refpoint (x_refpoint_, X_AXIS); @@ -196,11 +196,11 @@ Tie_formatting_problem::from_ties (Link_array const &ties) { Link_array bounds; - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) { Item *it = dynamic_cast (ties[i])->get_bound (d); - bounds.push (it); + bounds.push_back (it); } set_chord_outline (bounds, d); @@ -208,7 +208,7 @@ Tie_formatting_problem::from_ties (Link_array const &ties) while (flip (&d) != LEFT); - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) { Tie_specification spec; @@ -226,20 +226,20 @@ Tie_formatting_problem::from_ties (Link_array const &ties) } while (flip (&d) != LEFT); - specifications_.push (spec); + specifications_.push_back (spec); } } void Tie_formatting_problem::from_lv_ties (Link_array const &lv_ties) { - if (lv_ties.is_empty ()) - return ; + if (lv_ties.empty ()) + return; details_.from_grob (lv_ties[0]); Link_array heads; - for (int i = 0; i < lv_ties.size (); i++) + for (vsize i = 0; i < lv_ties.size (); i++) { Tie_specification spec; Item *head = unsmob_item (lv_ties[i]->get_object ("note-head")); @@ -253,12 +253,12 @@ Tie_formatting_problem::from_lv_ties (Link_array const &lv_ties) } spec.note_head_drul_[LEFT] = head; - heads.push (head); - specifications_.push (spec); + heads.push_back (head); + specifications_.push_back (spec); } x_refpoint_ = lv_ties [0]; - for (int i = 0; i < lv_ties.size (); i++) + for (vsize i = 0; i < lv_ties.size (); i++) { x_refpoint_ = lv_ties[i]->common_refpoint (x_refpoint_, X_AXIS); } @@ -267,7 +267,7 @@ Tie_formatting_problem::from_lv_ties (Link_array const &lv_ties) Real right_most = - infinity_f; - for (int i = 0; i < chord_outlines_[LEFT].size (); i++) + for (vsize i = 0; i < chord_outlines_[LEFT].size (); i++) { right_most = max (right_most, chord_outlines_[LEFT][i].height_); } @@ -276,7 +276,7 @@ Tie_formatting_problem::from_lv_ties (Link_array const &lv_ties) right_entry.width_.set_full (); right_entry.height_ = right_most + 1.5; - chord_outlines_[RIGHT].push (right_entry); + chord_outlines_[RIGHT].push_back (right_entry); } @@ -485,14 +485,14 @@ Tie_formatting_problem::find_optimal_tie_configuration (Tie_specification const int region_size = 3; for (int i = 0; i < region_size; i ++) { - confs.push (generate_configuration (pos + i * dir, dir)); + confs.push_back (generate_configuration (pos + i * dir, dir)); } - Array scores; + std::vector scores; int best_idx = -1; Real best_score = 1e6; - for (int i = 0; i < confs.size (); i ++) + for (vsize i = 0; i < confs.size (); i ++) { Real score = 0.0; score += score_configuration (*confs[i]); @@ -506,7 +506,7 @@ Tie_formatting_problem::find_optimal_tie_configuration (Tie_specification const } Tie_configuration best = *confs[best_idx]; - for (int i = 0; i < confs.size (); i++) + for (vsize i = 0; i < confs.size (); i++) delete confs[i]; return best; @@ -534,7 +534,7 @@ Tie_formatting_problem::score_ties_aptitude (Ties_configuration const &ties) con return infinity_f; } - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) score += score_aptitude (ties[i], specifications_[i]); return score; @@ -551,14 +551,14 @@ Real Tie_formatting_problem::score_ties_configuration (Ties_configuration const &ties) const { Real score = 0.0; - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) { score += score_configuration (ties[i]); } Real last_edge = 0.0; Real last_center = 0.0; - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) { Bezier b (ties[i].get_transformed_bezier (details_)); @@ -591,15 +591,15 @@ Tie_formatting_problem::score_ties_configuration (Ties_configuration const &ties score += details_.outer_tie_length_symmetry_penalty_factor_ - * fabs (ties[0].attachment_x_.length () - ties.top().attachment_x_.length ()); + * fabs (ties[0].attachment_x_.length () - ties.back ().attachment_x_.length ()); score += details_.outer_tie_vertical_distance_symmetry_penalty_factor_ * (fabs (specifications_[0].position_ - (ties[0].position_ * 0.5 * details_.staff_space_ + ties[0].delta_y_)) - - fabs (specifications_.top ().position_ - - (ties.top().position_ * 0.5 * details_.staff_space_ + ties.top().delta_y_))); + fabs (specifications_.back ().position_ + - (ties.back ().position_ * 0.5 * details_.staff_space_ + ties.back ().delta_y_))); return score; } @@ -612,7 +612,7 @@ Ties_configuration Tie_formatting_problem::generate_ties_configuration (Ties_configuration const &ties_config) { Ties_configuration copy; - for (int i = 0; i < ties_config.size (); i++) + for (vsize i = 0; i < ties_config.size (); i++) { Tie_configuration * ptr = get_configuration (ties_config[i].position_, ties_config[i].dir_); if (specifications_[i].has_manual_position_) @@ -621,7 +621,7 @@ Tie_formatting_problem::generate_ties_configuration (Ties_configuration const &t = (specifications_[i].manual_position_ - ties_config[i].position_) * 0.5 * details_.staff_space_; } - copy.push (*ptr); + copy.push_back (*ptr); } return copy; @@ -631,7 +631,7 @@ Ties_configuration Tie_formatting_problem::generate_base_chord_configuration () { Ties_configuration ties_config; - for (int i = 0; i < specifications_.size (); i ++) + for (vsize i = 0; i < specifications_.size (); i ++) { Tie_configuration conf; if (specifications_[i].has_manual_dir_) @@ -646,11 +646,11 @@ Tie_formatting_problem::generate_base_chord_configuration () { conf.position_ = specifications_[i].position_; } - ties_config.push (conf); + ties_config.push_back (conf); } set_ties_config_standard_directions (&ties_config); - for (int i = 0; i < ties_config.size (); i++) + for (vsize i = 0; i < ties_config.size (); i++) if (!specifications_[i].manual_position_) ties_config[i].position_ += ties_config[i].dir_; @@ -663,7 +663,7 @@ Ties_configuration Tie_formatting_problem::generate_optimal_chord_configuration () { Ties_configuration base = generate_base_chord_configuration (); - Array vars = get_variations (base); + std::vector vars = get_variations (base); Ties_configuration best = base; Real best_score = score_ties (best); @@ -672,7 +672,7 @@ Tie_formatting_problem::generate_optimal_chord_configuration () This simply is 1-opt: we have K substitions, and we try applying exactly every one for each. */ - for (int i = 0; i < vars.size (); i++) + for (vsize i = 0; i < vars.size (); i++) { Ties_configuration variant = base; variant[vars[i].index_] = *vars[i].suggestion_; @@ -691,18 +691,18 @@ Tie_formatting_problem::generate_optimal_chord_configuration () void Tie_formatting_problem::set_ties_config_standard_directions (Ties_configuration *tie_configs) { - if (tie_configs->is_empty ()) + if (tie_configs->empty ()) return ; if (!tie_configs->elem (0).dir_) tie_configs->elem_ref (0).dir_ = DOWN; - if (!tie_configs->top().dir_) - tie_configs->top().dir_ = UP; + if (!tie_configs->back ().dir_) + tie_configs->back ().dir_ = UP; /* Seconds */ - for (int i = 1; i < tie_configs->size (); i++) + for (vsize i = 1; i < tie_configs->size (); i++) { Real diff = (tie_configs->elem (i-1).position_ - tie_configs->elem (i).position_); @@ -716,7 +716,7 @@ Tie_formatting_problem::set_ties_config_standard_directions (Ties_configuration } } - for (int i = 1; i < tie_configs->size() - 1; i++) + for (vsize i = 1; i < tie_configs->size() - 1; i++) { Tie_configuration &conf = tie_configs->elem_ref (i); if (conf.dir_) @@ -737,14 +737,14 @@ Tie_configuration_variation::Tie_configuration_variation () suggestion_ = 0; } -Array +std::vector Tie_formatting_problem::get_variations (Ties_configuration const &ties) { Real center_distance_tolerance = 0.25; - Array vars; + std::vector vars; Real last_center = 0.0; - for (int i = 0; i < ties.size (); i++) + for (vsize i = 0; i < ties.size (); i++) { Bezier b (ties[i].get_transformed_bezier (details_)); @@ -762,7 +762,7 @@ Tie_formatting_problem::get_variations (Ties_configuration const &ties) - ties[i].dir_, -ties[i].dir_); - vars.push (var); + vars.push_back (var); } if (!specifications_[i-1].has_manual_dir_) @@ -773,7 +773,7 @@ Tie_formatting_problem::get_variations (Ties_configuration const &ties) - ties[i-1].dir_, - ties[i-1].dir_); - vars.push (var); + vars.push_back (var); } } } @@ -791,7 +791,7 @@ Tie_formatting_problem::get_variations (Ties_configuration const &ties) var.index_ = (d == DOWN) ? 0 : ties.size () - 1; var.suggestion_ = get_configuration (ties.boundary (d, 0).position_ + d, d); - vars.push (var); + vars.push_back (var); } } while (flip (&d) != DOWN); @@ -802,9 +802,9 @@ Tie_formatting_problem::get_variations (Ties_configuration const &ties) void Tie_formatting_problem::set_manual_tie_configuration (SCM manual_configs) { - int k = 0; + vsize k = 0; for (SCM s = manual_configs; - scm_is_pair (s) && k < specifications_.size(); s = scm_cdr (s)) + scm_is_pair (s) && k < specifications_.size (); s = scm_cdr (s)) { SCM entry = scm_car (s); if (scm_is_pair (entry)) diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index 24bc927a14..f122bcc865 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -17,8 +17,8 @@ class Tie_performer : public Performer { Music *event_; Music *last_event_; - Array now_heads_; - Array heads_to_tie_; + std::vector now_heads_; + std::vector heads_to_tie_; bool ties_created_; @@ -60,8 +60,8 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf) { if (Audio_note *an = dynamic_cast (inf.elem_)) { - now_heads_.push (inf); - for (int i = heads_to_tie_.size (); i--;) + now_heads_.push_back (inf); + for (vsize i = heads_to_tie_.size (); i--;) { Music *right_mus = inf.event_; diff --git a/lily/translator-dispatch-list.cc b/lily/translator-dispatch-list.cc index 319a976cbd..9197856597 100644 --- a/lily/translator-dispatch-list.cc +++ b/lily/translator-dispatch-list.cc @@ -17,7 +17,7 @@ void Engraver_dispatch_list::apply (Grob_info gi) { Translator *origin = gi.origin_translator (); - for (int i = 0; i < dispatch_entries_.size (); i++) + for (vsize i = 0; i < dispatch_entries_.size (); i++) { Engraver_dispatch_entry const &e (dispatch_entries_[i]); if (e.engraver_ == origin) @@ -52,7 +52,7 @@ Engraver_dispatch_list::create (SCM trans_list, if (ptr) { entry.function_ = ptr; - list->dispatch_entries_.push (entry); + list->dispatch_entries_.push_back (entry); found = true; } } diff --git a/lily/translator-group.cc b/lily/translator-group.cc index e821e784ca..e63dfdc6eb 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -176,7 +176,7 @@ Translator_group::precompute_method_bindings () for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++) { if (ptrs[i]) - precomputed_method_bindings_[i].push (Translator_method_binding (tr, ptrs[i])); + precomputed_method_bindings_[i].push_back (Translator_method_binding (tr, ptrs[i])); } } @@ -186,8 +186,8 @@ Translator_group::precompute_method_bindings () void Translator_group::precomputed_translator_foreach (Translator_precompute_index idx) { - Array &bindings (precomputed_method_bindings_[idx]); - for (int i = 0; i < bindings.size (); i++) + std::vector &bindings (precomputed_method_bindings_[idx]); + for (vsize i = 0; i < bindings.size (); i++) bindings[i].invoke (); } diff --git a/lily/translator.cc b/lily/translator.cc index d55fe15729..a11a33e822 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -159,7 +159,7 @@ Translator::print_smob (SCM s, SCM port, scm_print_state *) void add_acknowledger (Engraver_void_function_engraver_grob_info ptr, char const *func_name, - Array *ack_array) + std::vector *ack_array) { Acknowledge_information inf; inf.function_ = ptr; @@ -170,13 +170,13 @@ add_acknowledger (Engraver_void_function_engraver_grob_info ptr, interface_name += "-interface"; inf.symbol_ = scm_gc_protect_object (ly_symbol2scm (interface_name.c_str ())); - ack_array->push (inf); + ack_array->push_back (inf); } Engraver_void_function_engraver_grob_info -generic_get_acknowledger (SCM sym, Array const *ack_array) +generic_get_acknowledger (SCM sym, std::vector const *ack_array) { - for (int i = 0; i < ack_array->size (); i++) + for (vsize i = 0; i < ack_array->size (); i++) { if (ack_array->elem (i).symbol_ == sym) return ack_array->elem (i).function_; diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index e8b006f990..146499dbaa 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -81,7 +81,7 @@ Tuplet_bracket::parallel_beam (Grob *me_grob, Link_array const &cols, bool return 0; Drul_array stems (Note_column::get_stem (cols[0]), - Note_column::get_stem (cols.top ())); + Note_column::get_stem (cols.back ())); if (dynamic_cast (stems[RIGHT])->get_column () != me->get_bound (RIGHT)->get_column()) @@ -105,7 +105,7 @@ Tuplet_bracket::parallel_beam (Grob *me_grob, Link_array const &cols, bool return 0; } - *equally_long = (beam_stems[0] == stems[LEFT] && beam_stems.top () == stems[RIGHT]); + *equally_long = (beam_stems[0] == stems[LEFT] && beam_stems.back () == stems[RIGHT]); return beams[LEFT]; } @@ -128,7 +128,7 @@ Tuplet_bracket::calc_connect_to_neighbors (SCM smob) Spanner *orig_spanner = dynamic_cast (me->original ()); - int neighbor_idx = me->get_break_index () - break_dir; + vsize neighbor_idx = me->get_break_index () - break_dir; if (break_dir && d == RIGHT && neighbor_idx < orig_spanner->broken_intos_.size ()) @@ -208,9 +208,9 @@ Tuplet_bracket::calc_control_points (SCM smob) - overshoot[LEFT]; } else if (d == RIGHT - && (columns.is_empty () + && (columns.empty () || (bounds[d]->get_column () - != dynamic_cast (columns.top ())->get_column ()))) + != dynamic_cast (columns.back ())->get_column ()))) { /* TODO: make padding tunable? @@ -435,7 +435,7 @@ void Tuplet_bracket::get_bounds (Grob *me, Grob **left, Grob **right) { extract_grob_set (me, "note-columns", columns); - int l = 0; + vsize l = 0; while (l < columns.size () && Note_column::has_rests (columns[l])) l++; @@ -521,17 +521,17 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) Real x0 = robust_relative_extent (lgr, commonx, X_AXIS)[LEFT]; Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT]; - Array points; - points.push (Offset (x0 - x0, staff[dir])); - points.push (Offset (x1 - x0, staff[dir])); + std::vector points; + points.push_back (Offset (x0 - x0, staff[dir])); + points.push_back (Offset (x1 - x0, staff[dir])); - for (int i = 0; i < columns.size (); i++) + for (vsize i = 0; i < columns.size (); i++) { Interval note_ext = columns[i]->extent (commony, Y_AXIS); Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS); Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0; - points.push (Offset (x, notey)); + points.push_back (Offset (x, notey)); } /* @@ -541,7 +541,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) We assume that the smaller bracket is 1.0 space high. */ Real ss = Staff_symbol_referencer::staff_space (me); - for (int i = 0; i < tuplets.size (); i++) + for (vsize i = 0; i < tuplets.size (); i++) { Interval tuplet_x (tuplets[i]->extent (commonx, X_AXIS)); Interval tuplet_y (tuplets[i]->extent (commony, Y_AXIS)); @@ -571,13 +571,13 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) y += dir * my_height[d]; #endif - points.push (Offset (tuplet_x[d] - x0, y)); + points.push_back (Offset (tuplet_x[d] - x0, y)); } while (flip (&d) != LEFT); } Real factor = (columns.size () > 1) ? 1 / (x1 - x0) : 1.0; - for (int i = 0; i < points.size (); i++) + for (vsize i = 0; i < points.size (); i++) { Real x = points[i][X_AXIS]; Real tuplety = (*dy) * x * factor; @@ -667,7 +667,7 @@ Tuplet_bracket::get_default_dir (Grob *me) { Drul_array dirs (0, 0); extract_grob_set (me, "note-columns", columns); - for (int i = 0; i < columns.size (); i++) + for (vsize i = 0; i < columns.size (); i++) { Grob *nc = columns[i]; Direction d = Note_column::dir (nc); diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 1bdda38c69..3d24023e41 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -40,7 +40,7 @@ public: TRANSLATOR_DECLARATIONS (Tuplet_engraver); protected: - Array tuplets_; + std::vector tuplets_; Link_array last_tuplets_; DECLARE_ACKNOWLEDGER (note_column); virtual bool try_music (Music *r); @@ -67,7 +67,7 @@ Tuplet_engraver::try_music (Music *music) if (unsmob_moment (s)) d.span_stop_ = min (d.span_stop_, (now_mom () + *unsmob_moment (s)).main_part_); - tuplets_.push (d); + tuplets_.push_back (d); } return true; } @@ -81,7 +81,7 @@ Tuplet_engraver::process_music () return; tuplets_.sort (&Tuplet_description::compare); - for (int i = 0; i < tuplets_.size (); i++) + for (vsize i = 0; i < tuplets_.size (); i++) { if (tuplets_[i].bracket_) continue; @@ -111,7 +111,7 @@ Tuplet_engraver::process_music () void Tuplet_engraver::acknowledge_note_column (Grob_info inf) { - for (int j = 0; j < tuplets_.size (); j++) + for (vsize j = 0; j < tuplets_.size (); j++) if (tuplets_[j].bracket_) { Item *i = dynamic_cast (inf.grob ()); @@ -126,13 +126,13 @@ Tuplet_engraver::start_translation_timestep () Moment now = now_mom (); last_tuplets_.clear (); - if (tuplets_.is_empty ()) + if (tuplets_.empty ()) return; Moment tsdmom = robust_scm2moment (get_property ("tupletSpannerDuration"), Moment (0)); bool full_length = to_boolean (get_property ("tupletFullLength")); - for (int i = tuplets_.size (); i--;) + for (vsize i = tuplets_.size (); i--;) { Rational tsd = tsdmom.main_part_; @@ -154,8 +154,8 @@ Tuplet_engraver::start_translation_timestep () tuplets_[i].number_->set_bound (RIGHT, tuplets_[i].bracket_->get_bound (LEFT)); } - last_tuplets_.push (tuplets_[i].bracket_); - last_tuplets_.push (tuplets_[i].number_); + last_tuplets_.push_back (tuplets_[i].bracket_); + last_tuplets_.push_back (tuplets_[i].number_); tuplets_[i].bracket_ = 0; tuplets_[i].number_ = 0; @@ -175,7 +175,7 @@ Tuplet_engraver::finalize () { if (to_boolean (get_property ("tupletFullLength"))) { - for (int i = 0; i < last_tuplets_.size (); i++) + for (vsize i = 0; i < last_tuplets_.size (); i++) { Item *col = unsmob_item (get_property ("currentCommandColumn")); last_tuplets_[i]->set_bound (RIGHT, col); diff --git a/lily/vaticana-ligature-engraver.cc b/lily/vaticana-ligature-engraver.cc index bb535d3442..1c8abf7150 100644 --- a/lily/vaticana-ligature-engraver.cc +++ b/lily/vaticana-ligature-engraver.cc @@ -34,7 +34,7 @@ private: int context_info, int delta_pitch); bool is_stacked_head (int prefix_set, int context_info); - Real align_heads (Array primitives, + Real align_heads (std::vector primitives, Real flexa_width, Real thickness); @@ -44,7 +44,7 @@ public: protected: virtual Spanner *create_ligature_spanner (); virtual void transform_heads (Spanner *ligature, - Array primitives); + std::vector primitives); }; Vaticana_ligature_engraver::Vaticana_ligature_engraver () @@ -145,7 +145,7 @@ Vaticana_ligature_engraver::need_extra_horizontal_space (int prev_prefix_set, in } Real -Vaticana_ligature_engraver::align_heads (Array primitives, +Vaticana_ligature_engraver::align_heads (std::vector primitives, Real flexa_width, Real thickness) { @@ -180,7 +180,7 @@ Vaticana_ligature_engraver::align_heads (Array primitives, Item *prev_primitive = 0; int prev_prefix_set = 0; - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Item *primitive = dynamic_cast (primitives[i].grob ()); int prefix_set @@ -352,7 +352,7 @@ check_for_prefix_loss (Item *primitive) void Vaticana_ligature_engraver::transform_heads (Spanner *ligature, - Array primitives) + std::vector primitives) { Real flexa_width = robust_scm2double (ligature->get_property ("flexa-width"), 2); @@ -363,7 +363,7 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, int prev_context_info = 0; int prev_delta_pitch = 0; std::string prev_glyph_name = ""; - for (int i = 0; i < primitives.size (); i++) + for (vsize i = 0; i < primitives.size (); i++) { Item *primitive = dynamic_cast (primitives[i].grob ()); diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 890490069c..27f00f231b 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -120,7 +120,7 @@ Vertical_align_engraver::acknowledge_axis_group (Grob_info i) Link_array &arr = ga->array_reference (); Grob *added = arr.pop (); - for (int i = 0; i < arr.size (); i++) + for (vsize i = 0; i < arr.size (); i++) { if (arr[i] == before_grob) { diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc index 595ed9b192..561f0830f8 100644 --- a/lily/volta-bracket.cc +++ b/lily/volta-bracket.cc @@ -110,13 +110,13 @@ Volta_bracket_interface::after_line_breaking (SCM smob) bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me); - bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner *)me); + bool broken_last_bracket = orig_span && (orig_span->broken_intos_.back () == (Spanner *)me); bool no_vertical_start = orig_span && !broken_first_bracket; bool no_vertical_end = orig_span && !broken_last_bracket; extract_grob_set (me, "bars", bars); - Grob *endbar = bars.size () ? bars.top () : 0; + Grob *endbar = bars.size () ? bars.back () : 0; SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL; std::string str; -- 2.39.2