|
|
void | clear () |
| | Destroy all elements in the vector. Doesn't free the memory.
|
| template<typename Fn = default_eq> |
| bool | contains (const T &value, const Fn &comp=Fn{}) const |
| template<typename Fn = default_eq> |
| bool | is_set_equal (const kmp_vector &other, const Fn &comp=Fn{}) const |
|
void | push_back (const T &value) |
| | Add a new element to the end of the vector.
|
| void | reserve (size_t new_capacity) |
|
T * | begin () |
| | Iterator support (raw pointers work as iterators for contiguous storage).
|
template<typename T, size_t INLINE_THRESHOLD = 8>
class kmp_vector< T, INLINE_THRESHOLD >
kmp_vector is a vector class for managing small vectors. INLINE_THRESHOLD: Number of elements in the inline array. If exceeded, the vector will grow dynamically.
Definition at line 148 of file kmp_adt.h.
template<typename T, size_t INLINE_THRESHOLD = 8>
template<typename Fn = default_eq>
| bool kmp_vector< T, INLINE_THRESHOLD >::contains |
( |
const T & | value, |
|
|
const Fn & | comp = Fn{} ) const |
|
inline |
Check if the vector contains the given value. If a comparator is provided, it will be used to compare the values. Otherwise, the equality operator will be used.
Definition at line 271 of file kmp_adt.h.
template<typename T, size_t INLINE_THRESHOLD = 8>
| void kmp_vector< T, INLINE_THRESHOLD >::grow |
( |
size_t | MinSize = 0 | ) |
|
|
inlineprivate |
Grow by ~1.5x / at least by +1 element. If MinSize > 0, grow only if necessary to guarantee space for at least MinSize elements.
Definition at line 174 of file kmp_adt.h.
Referenced by push_back(), and reserve().
template<typename T, size_t INLINE_THRESHOLD = 8>
template<typename Fn = default_eq>
| bool kmp_vector< T, INLINE_THRESHOLD >::is_set_equal |
( |
const kmp_vector< T, INLINE_THRESHOLD > & | other, |
|
|
const Fn & | comp = Fn{} ) const |
|
inline |
Check if the two vectors are equal with set semantics. Current implementation is naive O(n^2) and not optimized for performance. Handles duplicates correctly.
Definition at line 287 of file kmp_adt.h.