|
| 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.reserve(10));
SC_TRY(myVector.push_back(1));
console.
print(
"[0]={}", myVector[0]);
SC_TRY(myVector.push_back(2));
SC_TRY(myVector.pop_back());
SC_TRY(myVector.pop_front());
console.
print(
"Vector<int> is {}", myVector.isEmpty() ?
"empty" :
"not empty");