Sane C++ Libraries: SC::Vector< T (original) (raw)

A contiguous sequence of heap allocated elements. More...

#include <[Vector.h](Vector%5F8h%5Fsource.html)>

Public Types
using Parent = Segment<detail::VectorVTable>
Public Member Functions
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

template
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 is {}", myVector.isEmpty() ? "empty" : "not empty");

contains()

template

template

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

template

Finds the first item in array matching criteria given by the lambda.

See also

Algorithms::findIf

remove()

template

template

bool SC::Vector< T >::remove ( const U & value) inlinenodiscardnoexcept

Removes all values equal to value

Template Parameters

Parameters

Returns

true if at least one item has been removed

removeAll()

template

template

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: