2006-02-06 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * flower/include/std-vector.hh: make sure vsize and VPOS are
+ defined for binary_search_bounds().
+
* flower/std-string.cc (std): add to_string(long unsigned).
* configure.in (gui_b): excise std_string option.
+++ /dev/null
-/*
- (c) 1995--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- Distributed under GNU GPL
-*/
-
-#if 0
-#include "std-vector.hh"
-#ifdef INLINE
-#undef INLINE
-#endif
-
-#define INLINE
-#endif
-
-/*
- functions with loops don't inline
-*/
-
-template<class T> INLINE void
-arrcpy (T *dest, T const *src, vsize count)
-{
- for (vsize i_shadows_local = 0; i_shadows_local < count; i_shadows_local++)
-#ifdef __powerpc__
- {
- /*
- urg: wierd egcs-1.1.2-12c (stock LinuxPPC R5) bug on ppc
- bug report filed
- fixed in egcs-1.1.2-12f
- ftp://dev.linuxppc.org/users/fsirl/R5/RPMS/ppc/
- */
- *dest = *src;
- dest++, src++;
- }
-#else
- *dest++ = *src++;
-#endif
-}
-
-template<class T> INLINE
-void
-Array<T>::OK () const
-{
-#if !STD_VECTOR
- assert (max_ >= size_ && size_ >= 0);
-#else
- assert (max_ >= size_);
-#endif
- if (max_)
- assert (array_);
-}
-
-template<class T> INLINE
-Array<T>::Array (const_iterator b, const_iterator e)
-{
- vsize n = e - b;
- array_ = new T[n];
- max_ = size_ = n;
- arrcpy (array_, b, n);
-}
-
-template<class T>
-void
-binary_search_bounds (Array<T> 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);
-}
-
-/*
- lookup with binsearch, return array index.
-*/
-template<class T>
-vsize
-binary_search (Array<T> 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;
-}
#undef vector
namespace std {
+
+ #ifndef VSIZE
+ #define VSIZE
+ typedef size_t vsize;
+ #define VPOS UINT_MAX
+ #endif
+
/* Interface without pointer arithmetic (iterator) semantics. */
template<typename T>
class vector : public __vector<T>
void
binary_search_bounds (vector<T*> const &table,
T const *key, int (*compare) (T *const &, T *const &),
- unsigned *lo,
- unsigned *hi)
+ vsize *lo,
+ vsize *hi)
{
- int cmp;
+ vsize cmp;
int result;
/* binary search */