]> git.donarmstrong.com Git - lilypond.git/commitdiff
* flower/include/std-vector.hh
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 2 Feb 2006 15:44:16 +0000 (15:44 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 2 Feb 2006 15:44:16 +0000 (15:44 +0000)
* flower/include/array.hh (reverse, swap): Detach from class.
Update users.

* flower/include/std-vector.hh
* flower/include/array.hh (concat): Globally change to insert ().

* flower/include/std-vector.hh
* flower/include/parray.hh
* flower/include/array.hh (elem, elem_ref): Globally replace by
at ().

ChangeLog
flower/include/array.hh
flower/include/parray.hh
flower/include/std-vector.hh
flower/polynomial.cc
flower/string-convert.cc
lily/beaming-info.cc
lily/tie-formatting-problem.cc

index 604b6deeaf3954d6d5bacb675bdafa3b05b6287c..76ed56b9918d5c368e9620b2ed21e54cb3e8bb5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2006-02-02  Jan Nieuwenhuizen  <janneke@gnu.org>
 
-       * flower/include/std-vector.hh
+       * flower/string-convert.cc (convert::unsigned_string): Bugfix:
+       remove superfluous `d'.
+
+       * flower/include/std-vector.hh (boundary, top): Detach from class.
+       Remove empty vector shell.
+
        * flower/include/array.hh (reverse, swap): Detach from class.
        Update users.
        
index 72cde837233aa698e0210b580105d8e2604dc98b..98e4d1f06050c48d16c93bbf59142e47b1ad51e5 100644 (file)
@@ -283,52 +283,43 @@ public:
     arrcpy (array_, src.array_, size_);
   }
 
-  /// access last entry
-  T &top (vsize j)
+  void unordered_del (vsize i)
   {
-    return (*this)[size_ - j - 1];
+    at (i) = back ();
+    resize (size () -1);
   }
-  /// return last entry
-  T top (vsize j) const
+};
+
+  template<typename T>
+  T const &
+  back (Array<T> const &v, vsize i)
   {
-    return (*this)[size_ - j - 1];
+    return v[v.size () - i - 1];
   }
 
-  T &boundary (int dir, vsize idx)
+  template<typename T>
+  T&
+  back (Array<T> &v, vsize i)
   {
-    assert (dir);
-    if (dir == 1)
-      return top (idx);
-    else
-      return at (idx);
+    return v[v.size () - i - 1];
   }
-  T boundary (int dir, vsize idx) const
+
+  template<typename T>
+  T const &
+  boundary (Array<T> const &v, int dir, vsize i)
   {
     assert (dir);
-    if (dir == 1)
-      return top (idx);
-    else
-      return at (idx);
+    return v[dir == 1 ? i : v.size () - 1 - i];
   }
 
-  void unordered_del (vsize i)
+  template<typename T>
+  T &
+  boundary (Array<T> &v, int dir, vsize i)
   {
-    at (i) = back ();
-    resize (size () -1);
+    assert (dir);
+    return v[dir == 1 ? i : v.size () - 1 - i];
   }
-};
 
-#if 0
-  template<class T>
-  void
-  swap (T *a, T *b)
-  {
-    T t = *a;
-    *a = *b;
-    *b = t;
-  }
-#endif
-  
   template<class T>
   void
   reverse (Array<T> &v)
index f5a2d373bf7ab4d1633c4fda204612367f89115a..2e90dd7c78c69eaf5aeaa352db4144e36a0fcfeb 100644 (file)
@@ -112,14 +112,13 @@ public:
     Array<void *>::push_back (t);
   }
 
-  /// return last entry
-  T *top (int j) const
+  T *top (vsize j)
   {
-    return (T *) Array<void *>::top (j);
+    return (*this)[size_ - j - 1];
   }
-  T *& top (int i)
+  T *& top (vsize j) const
   {
-    return (T *&) Array<void *>::top (i);
+    return (*this)[size_ - j - 1];
   }
 
   void substitute (T *old, T *new_p)
index c2226734b4cb37db597d17297290225ef4c84bea..10018dc1e74786f534cc288a51e4b07a533dcdce 100644 (file)
@@ -23,9 +23,7 @@
 
 #if STD_VECTOR
 
-#define vector __vector
 #include <vector>
-#undef vector
 
 namespace std {
 
@@ -35,55 +33,35 @@ namespace std {
   #define VPOS UINT_MAX
   #endif
 
-  /* Interface without pointer arithmetic (iterator) semantics.  */
   template<typename T>
-  class vector : public __vector<T>
+  T const &
+  boundary (vector<T> const &v, int dir, vsize i)
   {
-  public:
-    typedef typename __vector<T>::iterator iterator;
-    typedef typename __vector<T>::const_iterator const_iterator;
-
-    vector<T> () : __vector<T> ()
-    {
-    }
-
-    vector<T> (const_iterator b, const_iterator e) : __vector<T> (b, e)
-    {
-    }
-
-    /* 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);
-    }
+    assert (dir);
+    return v[dir == 1 ? i : v.size () - 1 - i];
+  }
 
-    T &
-    boundary (int dir, vsize i)
-    {
-      assert (dir);
-      if (dir == 1)
-       return this->top (i);
-      else
-       return this->at (i);
-    }
+  template<typename T>
+  T &
+  boundary (vector<T> &v, int dir, vsize i)
+  {
+    assert (dir);
+    return v[dir == 1 ? i : v.size () - 1 - i];
+  }
 
-    T const &
-    top (vsize i) const
-    {
-      return (*this)[this->size () - i - 1];
-    }
+  template<typename T>
+  T const &
+  back (vector<T> const &v, vsize i)
+  {
+    return v[v.size () - i - 1];
+  }
 
-    T&
-    top (vsize i)
-    {
-      return (*this)[this->size () - i - 1];
-    }
-  };
+  template<typename T>
+  T&
+  back (vector<T> &v, vsize i)
+  {
+    return v[v.size () - i - 1];
+  }
   
 #if 0
   template<typename T>
index 4d9687de38a3acdfe359f569b4a34a3cfeb5c7c4..5f719147674860a3cca8d4035b4282e80660625e 100644 (file)
@@ -88,7 +88,7 @@ Polynomial::clean ()
     We only do relative comparisons. Absolute comparisons break down in
     degenerate cases.  */
   while (degree () > 0
-        && (fabs (coefs_.back ()) < FUDGE * fabs (coefs_.top (1))
+        && (fabs (coefs_.back ()) < FUDGE * fabs (back (coefs_, 1))
             || !coefs_.back ()))
     coefs_.pop_back ();
 }
index 07aef9f3f41d1c9cdc37678117a42c2902e2dfdd..eda9aa9012eeae66c645ab4d43323015f74ff96e 100644 (file)
@@ -349,7 +349,7 @@ std::string
 String_convert::unsigned_string (unsigned u)
 {
   char s[STRING_BUFFER_LEN];
-  sprintf (s, "%ud", u);
+  sprintf (s, "%u", u);
   return s;
 }
 
index 11c6dde0c6ade6947db7f4144a6c78b71fd258cf..c4444c17a6553754b500fe523582b65a75625dc9 100644 (file)
@@ -53,8 +53,8 @@ Beaming_info_list::beam_extend_count (Direction d) const
   if (infos_.size () == 1)
     return infos_[0].beams_i_drul_[d];
 
-  Beaming_info thisbeam = infos_.boundary (d, 0);
-  Beaming_info next = infos_.boundary (d, 1);
+  Beaming_info thisbeam = boundary (infos_, d, 0);
+  Beaming_info next = boundary (infos_, d, 1);
 
   return min (thisbeam.beams_i_drul_[-d], next.beams_i_drul_[d]);
 }
@@ -87,7 +87,7 @@ Beaming_info_list::beamify (Moment &beat_length, bool subdivide)
   do
     {
       if (splits[d].infos_.size () != 1)
-       splits[d].infos_.boundary (-d, 0).beams_i_drul_[-d] = middle_beams;
+       boundary (splits[d].infos_, -d, 0).beams_i_drul_[-d] = middle_beams;
     }
   while (flip (&d) != LEFT);
 
index 4f3449caa27fcb343cec748e5a2da6646e5cf6ac..d1462d4f4b90ad0d7d31d2d8737a90da8f700185 100644 (file)
@@ -144,7 +144,7 @@ Tie_formatting_problem::set_chord_outline (Link_array<Item> bounds,
       Interval y;
       if (boxes.size())
        {
-         Box b = boxes.boundary (updowndir, 0);
+         Box b = boundary (boxes, updowndir, 0);
          x = b[X_AXIS];
          x[-d] =  b[X_AXIS].linear_combination (-d / 2);
          y[-updowndir] = b[Y_AXIS][updowndir];
@@ -785,12 +785,12 @@ Tie_formatting_problem::get_variations (Ties_configuration const &ties)
   Direction d = DOWN;
   do
     {
-      if (ties.boundary (d, 0).dir_ == d)
+      if (boundary (ties, d, 0).dir_ == d)
        {
          Tie_configuration_variation var;
          var.index_ = (d == DOWN) ? 0 : ties.size () - 1;
-         var.suggestion_ = get_configuration (ties.boundary (d, 0).position_ + d,
-                                              d);
+         var.suggestion_ = get_configuration (boundary (ties, d, 0).position_
+                                              + d, d);
          vars.push_back (var);
        }
     }