1 #ifndef SRC_CPP_COMMON_VECTOR_HPP
2 #define SRC_CPP_COMMON_VECTOR_HPP
5 #include "common/assert.h"
10 * Moves the last entry of `vec` to the index `idx`, then removes the last entry.
12 * Meant to be a direct replacement for g_ptr_array_remove_index_fast(), but for
15 template <typename T, typename AllocatorT>
16 void vectorFastRemove(std::vector<T, AllocatorT>& vec,
17 const typename std::vector<T, AllocatorT>::size_type idx)
19 BT_ASSERT_DBG(idx < vec.size());
21 if (idx < vec.size() - 1) {
22 vec[idx] = std::move(vec.back());
28 } /* namespace bt2_common */
30 #endif /* SRC_CPP_COMMON_VECTOR_HPP */