#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.
Public functions
- iterator begin() constexpr noexcept
- iterator end() constexpr noexcept
- const_iterator begin() const constexpr noexcept
- const_iterator end() const constexpr noexcept
-
reverse_
iterator rbegin() constexpr noexcept -
const_
reverse_ iterator rbegin() const constexpr noexcept -
reverse_
iterator rend() constexpr noexcept -
const_
reverse_ iterator rend() const constexpr noexcept - const_reference front() const constexpr
- const_reference back() const constexpr
- reference front() constexpr
- reference back() constexpr
- pointer data() constexpr noexcept
- const_pointer data() const constexpr noexcept
-
size_
type size() const constexpr noexcept -
size_
type capacity() const constexpr noexcept -
size_
type max_size() const constexpr noexcept - bool empty() const 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>reference emplace_back(Args && ... args)
- 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>iterator emplace(const_iterator pos, Args && ... args)
- Constructs a new element at the specified position in the array.
- iterator insert(const_iterator pos, const T& val)
- Inserts the given value at the specified position in the array.
- iterator insert(const_iterator pos, T&& val)
- Inserts the given value at the specified position in the array.
-
template<std::ranges::input_range TContainer>iterator insert_range(const_iterator pos, const TContainer& container)
- Inserts a range of elements at the specified position in the array.
-
template<std::input_iterator TIter>iterator insert(const_iterator pos, TIter first, TIter last)
- Inserts a range of elements at the specified position in the array.
-
iterator insert(const_iterator pos,
size_
type count, const T& value) - Inserts count copies of value at the specified position in the array.
- iterator erase(const_iterator pos)
- Removes the elements at pos from the array.
- iterator erase(const_iterator first, const_iterator last)
- Removes all elements between first and last from the array.
- void swap(SmallVectorBase& rhs)
- Swaps the contents of rhs with this array.
-
std::
span<T> copy(BumpAllocator& alloc) const - Creates a copy of the array using the given allocator.
-
std::
span<ConstElem> ccopy(BumpAllocator& alloc) const - Creates a constant copy of the array using the given allocator.
-
reference operator[](size_
type index) constexpr -
const_reference operator[](size_
type index) const constexpr -
reference at(size_
type index) constexpr -
const_reference at(size_
type index) const constexpr - bool isSmall() const 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. |
---|