#include <Containers/SmallVector.h>
template<typename T, unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
SmallVector class
Memory-optimized vector.
Template parameters | |
---|---|
T | Element type |
N | Number of in-place elements |
A variable-sized array optimized for the case when the array is small. It contains some number of elements in-place, which allows it to avoid heap allocation when the actual number of elements is below that threshold. This allows normal "small" cases to be fast without losing generality for large inputs.
Base classes
-
template<typename T>class SmallVectorImpl<T>
- Common method implementations of SmallVector class to reduce code duplication based on
N
template parameter.
Constructors, destructors, conversion operators
- SmallVector()
- Default constructor.
-
SmallVector(DefaultInitT,
std::
size_t size) explicit - Construct a default-initialized vector.
-
SmallVector(ValueInitT,
std::
size_t size) explicit - Construct a value-initialized vector.
- SmallVector(InPlaceInitT, ArrayView<const T> list)
- Construct a list-initialized vector.
-
template<typename ItTy, std::SmallVector(InPlaceInitT, ItTy s, ItTy e)
enable_if_t<std:: is_convertible<typename std:: iterator_traits<ItTy>::iterator_category, std:: input_iterator_tag>::value, int> = 0> -
SmallVector(InPlaceInitT,
std::
initializer_list<T> il) -
SmallVector(std::
size_t size) explicit - Construct a value-initialized vector.
- SmallVector(const SmallVector& other)
- Copy constructor.
- SmallVector(SmallVector&& other)
- Move constructor.
- SmallVector(SmallVectorImpl<T>&& other)
- ~SmallVector()
- Destructor.
Public functions
- auto operator=(const SmallVector& other) -> SmallVector&
- Copy assignment.
-
auto operator=(std::
initializer_list<T> il) -> SmallVector& - auto operator=(SmallVector&& other) -> SmallVector&
- Move assignment.
- auto operator=(SmallVectorImpl<T>&& other) -> SmallVector&
-
auto size() const -> std::
size_t - Returns the number of elements.
-
auto capacity() const -> std::
size_t - Returns the number of elements that can be held in currently allocated storage.
- auto empty() const -> bool
- Returns whether the container is empty.
- auto begin() -> iterator
- Returns an iterator to the beginning.
-
auto begin() const -> const_
iterator - auto end() -> iterator
- Returns an iterator to the end.
-
auto end() const -> const_
iterator -
auto rbegin() -> reverse_
iterator - Returns a reverse iterator to the beginning.
-
auto rbegin() const -> const_
reverse_ iterator -
auto rend() -> reverse_
iterator - Returns a reverse iterator to the end.
-
auto rend() const -> const_
reverse_ iterator -
auto size_in_bytes() const -> size_
type - Returns total size in bytes.
-
auto max_size() const -> size_
type - Returns maximum number of elements.
-
auto capacity_in_bytes() const -> std::
size_t - Returns capacity in bytes.
- auto data() -> pointer
- Returns a pointer to the vector's buffer.
-
auto data() const -> const_
pointer -
auto operator[](size_
type idx) -> reference - Access specified element.
-
auto operator[](size_
type idx) const -> const_ reference - auto front() -> reference
- Access the first element.
-
auto front() const -> const_
reference - auto back() -> reference
- Access the last element.
-
auto back() const -> const_
reference - void clear()
- Clears the vector.
-
void resize(size_
type n) - Resizes the vector to given size, value-initializing new elements.
-
void resize(size_
type n, ValueParamT nv) - Resizes the vector to given size, constructing new elements using provided argument.
-
void resize_for_overwrite(size_
type n) - Resizes the vector to given size, default-initializing new elements.
-
void truncate(size_
type n) - Like resize, but requires that
n
is less than size() -
void reserve(size_
type n) - Reserve given capacity in the vector.
- void push_back(const T& elt)
- Adds an element to the end.
- void push_back(T&& elt)
- void pop_back()
- Removes the last element.
-
void pop_back_n(size_
type n) - Removes the last
n
elements. - auto pop_back_val() -> T
- Removes the last element and returns it.
- void swap(SmallVectorImpl& other)
- Swaps the contents.
-
template<typename in_iter, std::void append(in_iter inStart, in_iter inEnd)
enable_if_t<std:: is_convertible<typename std:: iterator_traits<in_iter>::iterator_category, std:: input_iterator_tag>::value, int> = 0> - Adds the specified range to the end of the vector.
-
void append(size_
type n, ValueParamT elt) - Appends
n
copies ofelt
to the end. -
void append(std::
initializer_list<T> il) - Appends the specified list to the end.
- void append(const SmallVectorImpl& other)
- Appends the specified vector to the end.
-
void assign(size_
type n, ValueParamT elt) - Assigns
n
copies ofelt
. -
template<typename in_iter, std::void assign(in_iter inStart, in_iter inEnd)
enable_if_t<std:: is_convertible<typename std:: iterator_traits<in_iter>::iterator_category, std:: input_iterator_tag>::value, int> = 0> - Assigns the specified range.
-
void assign(std::
initializer_list<T> il) - Assigns the specified list.
- void assign(const SmallVectorImpl& other)
- Assigns the specified vector.
-
auto erase(const_
iterator ci) -> iterator - Removes elements from the vector.
-
auto erase(const_
iterator cs, const_ iterator ce) -> iterator -
void erase(size_
type index) -
auto eraseUnordered(const_
iterator ci) -> iterator - Removes an element from the unordered vector.
-
void eraseUnordered(size_
type index) - auto insert(iterator i, T&& elt) -> iterator
- Inserts elements.
- auto insert(iterator i, const T& elt) -> iterator
-
auto insert(iterator i,
size_
type numToInsert, ValueParamT elt) -> iterator -
template<typename ItTy, std::auto insert(iterator i, ItTy from, ItTy to) -> iterator
enable_if_t<std:: is_convertible<typename std:: iterator_traits<ItTy>::iterator_category, std:: input_iterator_tag>::value, int> = 0> -
void insert(iterator i,
std::
initializer_list<T> il)
Function documentation
template<typename T, unsigned N>
Death:: Containers:: SmallVector<T, N>:: SmallVector(DefaultInitT,
std:: size_t size) explicit
Construct a default-initialized vector.
Creates a vector of given size, the contents are default-initialized (i.e. trivial types are not initialized, default constructor called otherwise). If the size is zero, no allocation is done.
template<typename T, unsigned N>
Death:: Containers:: SmallVector<T, N>:: SmallVector(ValueInitT,
std:: size_t size) explicit
Construct a value-initialized vector.
Creates a vector of given size, the contents are value-initialized (i.e. trivial types are zero-initialized, default constructor called otherwise). This is the same as SmallVector(std::
template<typename T, unsigned N>
Death:: Containers:: SmallVector<T, N>:: SmallVector(InPlaceInitT,
ArrayView<const T> list)
Construct a list-initialized vector.
Copy-initializes each element with placement new using values from list
.
template<typename T, unsigned N>
template<typename ItTy, std:: enable_if_t<std:: is_convertible<typename std:: iterator_traits<ItTy>::iterator_category, std:: input_iterator_tag>::value, int> = 0>
Death:: Containers:: SmallVector<T, N>:: SmallVector(InPlaceInitT,
ItTy s,
ItTy e)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
Death:: Containers:: SmallVector<T, N>:: SmallVector(InPlaceInitT,
std:: initializer_list<T> il)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
Death:: Containers:: SmallVector<T, N>:: SmallVector(std:: size_t size) explicit
Construct a value-initialized vector.
Alias to SmallVector(ValueInitT, std::
template<typename T, unsigned N>
Death:: Containers:: SmallVector<T, N>:: SmallVector(SmallVectorImpl<T>&& other)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
SmallVector& Death:: Containers:: SmallVector<T, N>:: operator=(std:: initializer_list<T> il)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
SmallVector& Death:: Containers:: SmallVector<T, N>:: operator=(SmallVectorImpl<T>&& other)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ iterator Death:: Containers:: SmallVector<T, N>:: begin() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ iterator Death:: Containers:: SmallVector<T, N>:: end() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ reverse_ iterator Death:: Containers:: SmallVector<T, N>:: rbegin() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ reverse_ iterator Death:: Containers:: SmallVector<T, N>:: rend() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ pointer Death:: Containers:: SmallVector<T, N>:: data() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ reference Death:: Containers:: SmallVector<T, N>:: operator[](size_ type idx) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ reference Death:: Containers:: SmallVector<T, N>:: front() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
const_ reference Death:: Containers:: SmallVector<T, N>:: back() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
void Death:: Containers:: SmallVector<T, N>:: push_back(T&& elt)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
iterator Death:: Containers:: SmallVector<T, N>:: erase(const_ iterator cs,
const_ iterator ce)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
void Death:: Containers:: SmallVector<T, N>:: eraseUnordered(size_ type index)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
iterator Death:: Containers:: SmallVector<T, N>:: insert(iterator i,
size_ type numToInsert,
ValueParamT elt)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
template<typename ItTy, std:: enable_if_t<std:: is_convertible<typename std:: iterator_traits<ItTy>::iterator_category, std:: input_iterator_tag>::value, int> = 0>
iterator Death:: Containers:: SmallVector<T, N>:: insert(iterator i,
ItTy from,
ItTy to)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T, unsigned N>
void Death:: Containers:: SmallVector<T, N>:: insert(iterator i,
std:: initializer_list<T> il)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.