Sane C++ Libraries: SC::SmallVector< T, N (original) (raw)
A Vector that can hold up to N elements inline and > N on heap. More...
#include <[Vector.h](Vector%5F8h%5Fsource.html)>

| Public Member Functions | |
|---|---|
| SmallVector (SegmentAllocator allocator=SegmentAllocator::Global) noexcept | |
| SmallVector (const SmallVector &other) noexcept | |
| SmallVector (SmallVector &&other) noexcept | |
| SmallVector & | operator= (const SmallVector &other) noexcept |
| SmallVector & | operator= (SmallVector &&other) noexcept |
| SmallVector (const Vector< T > &other) noexcept | |
| SmallVector (Vector< T > &&other) noexcept | |
| SmallVector (std::initializer_list< T > list) noexcept | |
Public Member Functions inherited from SC::Vector< T > |
|
| template | |
| bool | contains (const U &value, size_t *index=nullptr) const noexcept |
| Check if the current array contains a given value. | |
| template | |
| bool | find (Lambda &&lambda, size_t *index=nullptr) const noexcept |
| Finds the first item in array matching criteria given by the lambda. | |
| template | |
| bool | removeAll (Lambda &&criteria) noexcept |
| Removes all items matching criteria given by Lambda. | |
| template | |
| bool | remove (const U &value) noexcept |
| Removes all values equal to value | |
| Protected Member Functions |
|---|
| Additional Inherited Members | |
|---|---|
Public Types inherited from SC::Vector< T > |
|
| using | Parent = Segment<detail::VectorVTable> |
template<typename T, int N>
struct SC::SmallVector< T, N >
A Vector that can hold up to N elements inline and > N on heap.
Template Parameters
| T | Type of single vector element |
|---|---|
| N | Number of elements kept inline to avoid heap allocation |
SC::SmallVector is like SC::Vector but it will do heap allocation once more than N elements are needed.
When the [size()](structSC%5F1%5F1Segment.html#a3141efbbe65178600af0fc97cff59e77) becomes less than N the container will switch back using memory coming from inline storage.
Note
SC::SmallVector derives from SC::Vector and it can be passed everywhere a reference to SC::Vector is needed. It can be used to get rid of unnecessary allocations where the upper bound of required elements is known or it can be predicted.
auto pushThreeIntegers = [](Vector& myVector) -> bool
{
SC_TRY(myVector.push_back(1));
SC_TRY(myVector.push_back(2));
SC_TRY(myVector.push_back(3));
return true;
};
SC_TRY(pushThreeIntegers(mySmallVector));
SC_TRY(mySmallVector.push_back(4));
SC_TRY(mySmallVector.pop_back());
The documentation for this struct was generated from the following file:
Public Member Functions inherited from