bool is_empty (void) const { return m_vecpfx.m_num == 0; }
T *address (void) { return m_vecdata; }
const T *address (void) const { return m_vecdata; }
+ T *begin () { return address (); }
+ const T *begin () const { return address (); }
+ T *end () { return address () + length (); }
+ const T *end () const { return address () + length (); }
const T &operator[] (unsigned) const;
T &operator[] (unsigned);
T &last (void);
void qsort (int (*) (const void *, const void *));
T *bsearch (const void *key, int (*compar)(const void *, const void *));
unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
+ bool contains (const T &search) const;
static size_t embedded_size (unsigned);
void embedded_init (unsigned, unsigned = 0, unsigned = 0);
void quick_grow (unsigned len);
return v ? v->is_empty () : true;
}
-
/* If V does not have space for NELEMS elements, call
V->reserve(NELEMS, EXACT). */
template<typename T, typename A>
}
}
+/* Return true if SEARCH is an element of V. Note that this is O(N) in the
+ size of the vector and so should be used with care. */
+
+template<typename T, typename A>
+inline bool
+vec_safe_contains (vec<T, A, vl_embed> *v, const T &search)
+{
+ return v ? v->contains (search) : false;
+}
/* Index into vector. Return the IX'th element. IX must be in the
domain of the vector. */
return NULL;
}
+/* Return true if SEARCH is an element of V. Note that this is O(N) in the
+ size of the vector and so should be used with care. */
+
+template<typename T, typename A>
+inline bool
+vec<T, A, vl_embed>::contains (const T &search) const
+{
+ unsigned int len = length ();
+ for (unsigned int i = 0; i < len; i++)
+ if ((*this)[i] == search)
+ return true;
+
+ return false;
+}
/* Find and return the first position in which OBJ could be inserted
without changing the ordering of this vector. LESSTHAN is a
const T *address (void) const
{ return m_vec ? m_vec->m_vecdata : NULL; }
+ T *begin () { return address (); }
+ const T *begin () const { return address (); }
+ T *end () { return begin () + length (); }
+ const T *end () const { return begin () + length (); }
const T &operator[] (unsigned ix) const
{ return (*m_vec)[ix]; }
void qsort (int (*) (const void *, const void *));
T *bsearch (const void *key, int (*compar)(const void *, const void *));
unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
+ bool contains (const T &search) const;
bool using_auto_storage () const;
return m_vec ? m_vec->lower_bound (obj, lessthan) : 0;
}
+/* Return true if SEARCH is an element of V. Note that this is O(N) in the
+ size of the vector and so should be used with care. */
+
+template<typename T>
+inline bool
+vec<T, va_heap, vl_ptr>::contains (const T &search) const
+{
+ return m_vec ? m_vec->contains (search) : false;
+}
+
template<typename T>
inline bool
vec<T, va_heap, vl_ptr>::using_auto_storage () const