A contiguous sequence of heap allocated elements.
More...
#include <Vector.h>
|
using | Parent = Segment<detail::VectorVTable<T>> |
|
|
template<typename U > |
bool | contains (const U &value, size_t *index=nullptr) const noexcept |
| Check if the current array contains a given value.
|
|
template<typename Lambda > |
bool | find (Lambda &&lambda, size_t *index=nullptr) const noexcept |
| Finds the first item in array matching criteria given by the lambda.
|
|
template<typename Lambda > |
bool | removeAll (Lambda &&criteria) noexcept |
| Removes all items matching criteria given by Lambda.
|
|
template<typename U > |
bool | remove (const U &value) noexcept |
| Removes all values equal to value
|
|
template<typename T>
struct SC::Vector< T >
A contiguous sequence of heap allocated elements.
- Template Parameters
-
T | Type of single vector element |
All methods of SC::Vector that can fail, return a [[nodiscard]]
bool
(example SC::Vector::push_back).
Assignment and Copy / move construct operators will just assert as they can't return a failure code.
memcpy
is used to optimize copies when T
is a memcpy-able object.
- Note
- Use SC::SmallVector everywhere a SC::Vector reference is needed if the upper bound size of required elements is known to get rid of unnecessary heap allocations.
SC_TRY(myVector.push_back(1));
console.
print(
"[0]={}", myVector[0]);
SC_TRY(myVector.push_back(2));
console.
print(
"Vector<int> is {}", myVector.isEmpty() ?
"empty" :
"not empty");
◆ contains()
template<typename T >
template<typename U >
bool SC::Vector< T >::contains |
( |
const U & | value, |
|
|
size_t * | index = nullptr ) const |
|
inlinenodiscardnoexcept |
Check if the current array contains a given value.
- See also
- Algorithms::contains
◆ find()
template<typename T >
template<typename Lambda >
Finds the first item in array matching criteria given by the lambda.
- See also
- Algorithms::findIf
◆ remove()
template<typename T >
template<typename U >
Removes all values equal to value
- Template Parameters
-
- Parameters
-
- Returns
true
if at least one item has been removed
◆ removeAll()
template<typename T >
template<typename Lambda >
bool SC::Vector< T >::removeAll |
( |
Lambda && | criteria | ) |
|
|
inlinenodiscardnoexcept |
Removes all items matching criteria given by Lambda.
- See also
- Algorithms::removeIf
The documentation for this struct was generated from the following file: