#include <slang/util/SmallVector.h>
template<typename T>
SmallVectorBase class
Base class for a fast growable array.
SmallVector is a vector-like growable array that allocates its first N elements on the stack. As long as you don't need more room than that, there are no heap allocations – otherwise we spill over into the heap. This is the base class that erases the stack size template parameter for use with generic code.
Derived classes
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
Public functions
- auto begin() -> iterator constexpr noexcept
- auto end() -> iterator constexpr noexcept
- auto begin() const -> const_iterator constexpr noexcept
- auto end() const -> const_iterator constexpr noexcept
-
auto rbegin() -> reverse_
iterator constexpr noexcept -
auto rbegin() const -> const_
reverse_ iterator constexpr noexcept -
auto rend() -> reverse_
iterator constexpr noexcept -
auto rend() const -> const_
reverse_ iterator constexpr noexcept - auto front() const -> const_reference constexpr
- auto back() const -> const_reference constexpr
- auto front() -> reference constexpr
- auto back() -> reference constexpr
- auto data() -> pointer constexpr noexcept
- auto data() const -> const_pointer constexpr noexcept
-
auto size() const -> size_
type constexpr noexcept -
auto capacity() const -> size_
type constexpr noexcept -
auto max_size() const -> size_
type constexpr noexcept - auto empty() const -> bool constexpr noexcept
-
void reserve(size_
type newCapacity) - Ensures that there is enough allocated memory in the array for at least size objects.
-
void resize(size_
type newSize) - Resizes the array.
-
void resize(size_
t newSize, const T& value) - Resizes the array.
-
void resize_for_overwrite(size_
type newSize) - Resizes the array.
- void clear() noexcept
- Clears all elements but retain underlying storage.
- void pop_back()
- Removes the last element from the array. The array must not be empty!
- void push_back(const T& item)
- Adds an element to the end of the array.
- void push_back(T&& item)
- Adds an element to the end of the array.
-
template<typename... Args>auto emplace_back(Args && ... args) -> reference
- Constructs a new element at the end of the array.
-
template<std::input_iterator TIter>void append(TIter first, TIter last)
- Appends a range of elements to the end of the array.
-
template<std::ranges::input_range TContainer>void append_range(const TContainer& container)
- Appends a range of elements to the end of the array.
-
void append(size_
type count, const T& value) - Appends count copies of value to the end of the array.
-
void assign(size_
type count, const T& value) - Resets the contents of the array to be count copies of value.
-
template<std::input_iterator TIter>void assign(TIter first, TIter last)
- Resets the contents of the array to be the contents of the given range.
-
template<std::ranges::input_range TContainer>void assign_range(const TContainer& container)
- Resets the contents of the array to be the contents of the given range.
-
template<typename... Args>auto emplace(const_iterator pos, Args && ... args) -> iterator
- Constructs a new element at the specified position in the array.
- auto insert(const_iterator pos, const T& val) -> iterator
- Inserts the given value at the specified position in the array.
- auto insert(const_iterator pos, T&& val) -> iterator
- Inserts the given value at the specified position in the array.
-
template<std::ranges::input_range TContainer>auto insert_range(const_iterator pos, const TContainer& container) -> iterator
- Inserts a range of elements at the specified position in the array.
-
template<std::input_iterator TIter>auto insert(const_iterator pos, TIter first, TIter last) -> iterator
- Inserts a range of elements at the specified position in the array.
-
auto insert(const_iterator pos,
size_
type count, const T& value) -> iterator - Inserts count copies of value at the specified position in the array.
- auto erase(const_iterator pos) -> iterator
- Removes the elements at pos from the array.
- auto erase(const_iterator first, const_iterator last) -> iterator
- Removes all elements between first and last from the array.
- void swap(SmallVectorBase& rhs)
- Swaps the contents of rhs with this array.
-
auto copy(BumpAllocator& alloc) const -> std::
span<T> - Creates a copy of the array using the given allocator.
-
auto ccopy(BumpAllocator& alloc) const -> std::
span<ConstElem> - Creates a constant copy of the array using the given allocator.
-
auto operator[](size_
type index) -> reference constexpr -
auto operator[](size_
type index) const -> const_reference constexpr -
auto at(size_
type index) -> reference constexpr -
auto at(size_
type index) const -> const_reference constexpr - auto isSmall() const -> bool constexpr noexcept
- Indicates whether we are still "small", which means we are still on the stack.
Function documentation
template<typename T>
iterator slang:: SmallVectorBase<T>:: begin() constexpr noexcept
Returns | an iterator to the beginning of the array. |
---|
template<typename T>
iterator slang:: SmallVectorBase<T>:: end() constexpr noexcept
Returns | an iterator to the end of the array. |
---|
template<typename T>
const_iterator slang:: SmallVectorBase<T>:: begin() const constexpr noexcept
Returns | an iterator to the beginning of the array. |
---|
template<typename T>
const_iterator slang:: SmallVectorBase<T>:: end() const constexpr noexcept
Returns | an iterator to the end of the array. |
---|
template<typename T>
reverse_ iterator slang:: SmallVectorBase<T>:: rbegin() constexpr noexcept
Returns | a reverse iterator to the end of the array. |
---|
template<typename T>
const_ reverse_ iterator slang:: SmallVectorBase<T>:: rbegin() const constexpr noexcept
Returns | a reverse iterator to the end of the array. |
---|
template<typename T>
reverse_ iterator slang:: SmallVectorBase<T>:: rend() constexpr noexcept
Returns | a reverse iterator to the end of the array. |
---|
template<typename T>
const_ reverse_ iterator slang:: SmallVectorBase<T>:: rend() const constexpr noexcept
Returns | a reverse iterator to the end of the array. |
---|
template<typename T>
const_reference slang:: SmallVectorBase<T>:: front() const constexpr
Returns | a reference to the first element in the array. The array must not be empty! |
---|
template<typename T>
const_reference slang:: SmallVectorBase<T>:: back() const constexpr
Returns | a reference to the last element in the array. The array must not be empty! |
---|
template<typename T>
reference slang:: SmallVectorBase<T>:: front() constexpr
Returns | a reference to the first element in the array. The array must not be empty! |
---|
template<typename T>
reference slang:: SmallVectorBase<T>:: back() constexpr
Returns | a reference to the last element in the array. The array must not be empty! |
---|
template<typename T>
pointer slang:: SmallVectorBase<T>:: data() constexpr noexcept
Returns | a pointer to the underlying array. |
---|
template<typename T>
const_pointer slang:: SmallVectorBase<T>:: data() const constexpr noexcept
Returns | a pointer to the underlying array. |
---|
template<typename T>
bool slang:: SmallVectorBase<T>:: empty() const constexpr noexcept
Returns | true if the array is empty, and false if it has elements in it. |
---|
template<typename T>
void slang:: SmallVectorBase<T>:: resize_for_overwrite(size_ type newSize)
Resizes the array.
If larger than the current size, default constructs new elements to fill the gap. If smaller than the current size, the length is shrunk and elements are destructed.
template<typename T>
std:: span<ConstElem> slang:: SmallVectorBase<T>:: ccopy(BumpAllocator& alloc) const
Creates a constant copy of the array using the given allocator.
If the array holds pointers, const is added to the pointed-to type as well.
template<typename T>
reference slang:: SmallVectorBase<T>:: operator[](size_ type index) constexpr
Returns | the element at the given position in the array. |
---|
template<typename T>
const_reference slang:: SmallVectorBase<T>:: operator[](size_ type index) const constexpr
Returns | the element at the given position in the array. |
---|