- /* Interface without pointer arithmetic (iterator) semantics. */
- template<typename T>
- class vector : public __vector<T>
- {
- 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);
- }
-
- T &
- boundary (int dir, vsize i)
- {
- assert (dir);
- if (dir == 1)
- return this->top (i);
- else
- return this->at (i);
- }
-
- 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<typename T>
- vsize
- // binary_search (std::vector<T> const &v,
- binary_search (vector<T> const &v,
- T const &key, int (*compare) (T const &, T const &),
- vsize b=0, vsize e=VPOS)
- {
- //(void) compare;
- typename vector<T>::const_iterator 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<class T>
- void
- binary_search_bounds (vector<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);
- }