LLVM OpenMP* Runtime Library
Loading...
Searching...
No Matches
kmp_vector< T, INLINE_THRESHOLD > Class Template Referencefinal

#include <kmp_adt.h>

Public Member Functions

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).

Private Member Functions

void grow (size_t MinSize=0)
void move_from (kmp_vector &&other)
 Move data from other vector to this vector (which must be emptied before).

Detailed Description

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.

Member Function Documentation

◆ contains()

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.

◆ grow()

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().

◆ is_set_equal()

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.

◆ reserve()

template<typename T, size_t INLINE_THRESHOLD = 8>
void kmp_vector< T, INLINE_THRESHOLD >::reserve ( size_t new_capacity)
inline

Reserve space for the given number of elements. (Note: does not shrink the vector.)

Definition at line 313 of file kmp_adt.h.


The documentation for this class was generated from the following file: