]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/std-vector.hh
Run `make grand-replace'.
[lilypond.git] / flower / include / std-vector.hh
index 55b28d7da641cb9701dc09125a48942ba509b12c..76a11bb9252237189463c667290df2cd01ecc183 100644 (file)
@@ -3,19 +3,30 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2006 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2006--2008 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #ifndef STD_VECTOR_HH
 #define STD_VECTOR_HH
 
+#if 0
+
+/*
+  leads to dubious crashes - libstdc++  bug?
+*/
+#ifndef NDEBUG
+#define _GLIBCXX_DEBUG 1
+#endif
+#endif
+
 #include <algorithm>   /* find, reverse, sort */
 #include <functional>  /* unary_function */
 #include <cassert>
+#include <string>
 
 using namespace std;
 
-#if HAVE_BOOST_LAMBDA
+#if HAVE_BOOST_LAMBDA_LAMBDA_HPP
 #include <boost/lambda/lambda.hpp>
 #endif
 
@@ -181,46 +192,17 @@ binary_search (vector<T> const &v,
   return lb;
 }
 
-#if 0
-/* FIXME: the COMPARE functionality is broken?  */
-template<typename T>
+template<typename T, typename Compare>
 void
-vector_sort (vector<T> &v, int (*compare) (T const &, T const &),
-            vsize lower=VPOS, vsize upper=VPOS)
+vector_sort (vector<T> &v,
+            Compare less,
+            vsize b=0, vsize e=VPOS)
 {
-  typename vector<T>::iterator b = v.begin ();
-  typename vector<T>::iterator e = v.begin ();
-  if (lower == VPOS)
-    {
-      lower = 0;
-      upper = v.size ();
-    }
-  sort (b + lower, e + upper, compare);
-}
-#else
+  if (e == VPOS)
+    e = v.size ();
 
-// ugh, c&p
-template<typename T> void
-vector_sort (vector<T> &v, int (*compare) (T const &, T const &),
-            vsize lower=VPOS, vsize upper=VPOS)
-{
-  if (lower == VPOS)
-    {
-      lower = 0;
-      upper = v.size () - 1;
-    }
-  if (upper == VPOS || lower >= upper)
-    return;
-  swap (v[lower], v[(lower + upper) / 2]);
-  vsize last = lower;
-  for (vsize i = lower +1; i <= upper; i++)
-    if (compare (v[i], v[lower]) < 0)
-      swap (v[++last], v[i]);
-  swap (v[lower], v[last]);
-  vector_sort (v, compare, lower, last - 1);
-  vector_sort (v, compare, last + 1, upper);
+  sort (v.begin () + b, v.begin () + e, less);
 }
-#endif
 
 template<typename T>
 void
@@ -245,7 +227,7 @@ find (vector<T> const &v, T const &key)
   return find (v.begin (), v.end (), key);
 }
 
-#if HAVE_BOOST_LAMBDA
+#if HAVE_BOOST_LAMBDA_LAMBDA_HPP
 #include <boost/lambda/lambda.hpp>
 using namespace boost::lambda;
 template<typename T>
@@ -277,6 +259,7 @@ junk_pointers (vector<T> &v)
 #endif /* HAVE_BOOST_LAMBDA */
 
 vector<string> string_split (string str, char c);
+string string_join (vector<string> const &strs, string infix);
 
 #define iterof(i,s) typeof((s).begin()) i((s).begin())