From: Jan Nieuwenhuizen Date: Fri, 3 Feb 2006 15:50:05 +0000 (+0000) Subject: * flower/include/std-vector.hh[STD_VECTOR]: Do not include X-Git-Tag: release/2.7.31~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6c68e65859bae109509e1c464fdfca6de4b5ddd1;p=lilypond.git * flower/include/std-vector.hh[STD_VECTOR]: Do not include array.hh, parray.hh at all. Getting ready to flip the configure default. * lily/include/lily-proto.hh (Link_array__char_): Bugfix. * lily/source-file.cc (file::get_line): Help binary_search_bounds a bit. * lily/include/lily-proto.hh (Link_array__char_): Bugfix. --- diff --git a/ChangeLog b/ChangeLog index 27cc759899..9ccc5d06aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-02-03 Jan Nieuwenhuizen + + * flower/include/std-vector.hh[STD_VECTOR]: Do not include + array.hh, parray.hh at all. Getting ready to flip the + configure default. + + * lily/include/lily-proto.hh (Link_array__char_): Bugfix. + + * lily/source-file.cc (file::get_line): Help binary_search_bounds + a bit. + + * lily/include/lily-proto.hh (Link_array__char_): Bugfix. + 2006-02-03 Han-Wen Nienhuys * flower/include/array.hh: typo. diff --git a/flower/include/std-vector.hh b/flower/include/std-vector.hh index 3fa220184e..e8367ae8a6 100644 --- a/flower/include/std-vector.hh +++ b/flower/include/std-vector.hh @@ -125,31 +125,6 @@ namespace std { while (*hi - *lo > 1); } - template - void - binary_search_bounds (vector const &table, - T const *key, int (*compare) (T *const &, T *const &), - int *lo, - int *hi) - { - int cmp; - int result; - - /* binary search */ - do - { - cmp = (*lo + *hi) / 2; - - result = (*compare) ((T *) key, table[cmp]); - - if (result < 0) - *hi = cmp; - else - *lo = cmp; - } - while (*hi - *lo > 1); - } - #if 0 template vsize @@ -310,11 +285,11 @@ namespace std { } -#endif /* STD_VECTOR */ - #include "array.hh" #include "parray.hh" +#endif /* !STD_VECTOR */ + using namespace std; #endif /* STD_VECTOR_HH */ diff --git a/flower/test-std.cc b/flower/test-std.cc index 6e53f987ad..e6f0da3d3e 100644 --- a/flower/test-std.cc +++ b/flower/test-std.cc @@ -179,6 +179,16 @@ BOOST_AUTO_UNIT_TEST (vector_search) test_suite* init_unit_test_suite (int, char**) { + vsize i = 0; + vsize j = 0; + vector v; + binary_search_bounds (v, 1, &default_compare, &i, &j); + //binary_search_bounds (v, 1, &default_compare, 0, 0); + + //Link_array w; + vector w; + binary_search_bounds (w, (char*)1, &default_compare, &i, &j); + test_suite *test = BOOST_TEST_SUITE("std::Flower"); test->add (BOOST_TEST_CASE (vector_erase)); test->add (BOOST_TEST_CASE (vector_slice)); diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index ccbd177226..30603aff77 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -180,11 +180,7 @@ typedef void (*Translator_void_method_ptr) (Translator *); /* FIXME: when Link_array is dropped, do grand s/r to vector. */ #if STD_VECTOR - -// FIXME: does not work with sourc-file.cc -// #define Link_array__char_ std::vector - -#define Link_array__char_ Link_array +#define Link_array__char_ std::vector #define Link_array__Grob_ std::vector #define Link_array__Accidental_placement_entry_ std::vector #define Link_array__Audio_item_ std::vector diff --git a/lily/source-file.cc b/lily/source-file.cc index 041308dbc8..d9c022b157 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -313,8 +313,8 @@ Source_file::get_line (char const *pos_str0) const if (!newline_locations_.size ()) return 1; - int lo = 0; - int hi = newline_locations_.size (); + vsize lo = 0; + vsize hi = newline_locations_.size (); if (newline_locations_[lo] > pos_str0) return 1; @@ -323,7 +323,7 @@ Source_file::get_line (char const *pos_str0) const return hi; binary_search_bounds (newline_locations_, - pos_str0, + (char const*)pos_str0, default_compare, &lo, &hi);