omni::graph::exec::unstable::SmallVector
Defined in omni/graph/exec/unstable/SmallVector.h
-
template<typename T, std::size_t N>
class SmallVector : public omni::graph::exec::unstable::SmallVectorBase This is a small-vector class with local storage optimization, the local storage can be specified via a template parameter, and expresses the number of entries the container can store locally.
In addition to the local storage optimization, this vector is also optimized for storing a smaller number of entries on the heap: It features a reduced memory footprint (minimum 16 bytes) by limiting max_size() to 2^32, which should still be more than enough for most use cases where a small-vector is advantageous.
SmallVector mimics the std::vector API, and can thus be easily used as a drop-in replacement where appropriate. Note, however, that not all the methods on std::vector are implemented here, and that SmallVector may have methods in addition to those that you would find on std::vector.
Note that a SmallVector that has grown beyond its local storage, will NOT move its entries back into the local storage once it shrinks back to N.
Unnamed Group
-
using const_reverse_iterator = std::reverse_iterator<const_iterator>
Iterator Support.
-
template<typename _ForwardIterator>
using _EnableIfForwardIterator = typename std::enable_if<std::is_convertible<typename std::iterator_traits<_ForwardIterator>::iterator_category, std::forward_iterator_tag>::value>::type Compile time check to enabled method when forward iterator is available.
-
inline SmallVector()
}@
Default constructor.
-
inline SmallVector(size_type n, const value_type &v)
Construct a vector holding
n
copies ofv
.
-
inline SmallVector(size_type n, DefaultInitTag)
Construct a vector holding
n
default-initialized elements.
-
inline SmallVector(const SmallVector &rhs)
Copy constructor.
-
inline SmallVector(SmallVector &&rhs)
Move constructor.
-
template<typename ForwardIterator, typename = _EnableIfForwardIterator<ForwardIterator>>
inline SmallVector(ForwardIterator first, ForwardIterator last) Creates a new vector containing copies of the data between
first
andlast
.
-
inline ~SmallVector()
Destructor.
-
inline SmallVector &operator=(const SmallVector &rhs)
Assignment operator.
-
inline SmallVector &operator=(SmallVector &&rhs)
Move assignment operator.
-
inline SmallVector &operator=(std::initializer_list<T> ilist)
Replace existing contents with the contents of
ilist
.
-
inline void swap(SmallVector &rhs)
Swap two vector instances.
-
inline iterator insert(const_iterator it, value_type &&v)
Insert an rvalue-reference entry at the given iterator position.
-
inline iterator insert(const_iterator it, const value_type &v)
Insert an entry at the given iterator.
-
inline iterator erase(const_iterator it)
Erase an entry at the given iterator.
-
inline iterator erase(const_iterator it, const_iterator last)
Erase entries between [
first
,last
) from the vector.
-
inline void resize(size_type newSize, const value_type &v = value_type())
Resize the vector to
newSize
and insert copies ofv
.
-
inline void clear()
Clear the entries in the vector. Does not let go of the underpinning storage.
-
template<typename ForwardIterator, typename = _EnableIfForwardIterator<ForwardIterator>>
inline void assign(ForwardIterator first, ForwardIterator last) Clears any previously held entries, and copies entries between [
first
,last
) to this vector.
-
inline void assign(std::initializer_list<T> ilist)
Replace existing contents with the contents of
ilist
.
-
template<typename ...Args>
inline void emplace_back(Args&&... args) Emplace an entry at the back of the vector.
-
inline void push_back(const value_type &v)
Copy an entry to the back of the vector,.
-
inline void push_back(value_type &&v)
Move an entry to the back of the vector.
-
template<typename ForwardIterator>
inline void insert(iterator pos, ForwardIterator first, ForwardIterator last) Copy the range denoted by [
first
,last
) into this vector beforepos
.
-
inline void insert(iterator pos, std::initializer_list<T> ilist)
Insert elements from
ilist
starting at positionpos
.
-
inline void pop_back()
Remove the entry at the back of the vector.
-
inline bool empty() const
Returns
true
if this vector is empty.
-
inline size_type capacity() const
Returns the current capacity of this vector. Note that if the returned value is <= N, it does NOT mean the storage is local. A vector that has previously grown beyond its local storage, will not move entries back to the local storage once it shrinks to N.
-
inline const_iterator begin() const
Returns an iterator to the beginning of the vector.
-
inline const_iterator cbegin() const
Returns an iterator to the beginning of the vector.
Unnamed Group
-
inline const_iterator end() const
Returns an iterator to the end of the vector.
-
inline const_iterator cend() const
Returns an iterator to the end of the vector.
Unnamed Group
-
inline reverse_iterator rbegin()
Returns a reverse iterator to the beginning of the vector.
-
inline const_reverse_iterator rbegin() const
Returns a reverse iterator to the beginning of the vector.
-
inline const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning of the vector.
Unnamed Group
-
inline reverse_iterator rend()
Returns a reverse iterator to the end of the vector.
-
inline const_reverse_iterator rend() const
Returns a reverse iterator to the end of the vector.
-
inline const_reverse_iterator crend() const
Returns a reverse iterator to the end of the vector.
Public Types
-
using size_type = std::uint32_t
Size type.
-
using difference_type = std::uint32_t
Difference type.
Public Functions
-
inline const_reference front() const
Returns the first element in the vector.
-
inline const_reference back() const
Returns the last elements in the vector.
-
inline const_reference operator[](size_type i) const
Access the specified element.
-
inline value_type *data()
Direct access to the underlying array.
-
inline const value_type *data() const
Direct access to the underlying array.
-
inline bool operator==(const SmallVector &rhs) const
Lexicographically compares the elements in the vectors for equality.
-
inline bool operator!=(const SmallVector &rhs) const
Lexicographically compares the elements in the vectors for inequality.
Public Static Functions
-
template<typename U>
static inline constexpr size_type ComputeSerendipitousLocalCapacity() Returns the local capacity that may be used without increasing the size of the SmallVector. SmallVector<T, N> will never use more local capacity than is specified by N but clients that wish to maximize local occupancy in a generic way can compute N using this function.
-
using const_reverse_iterator = std::reverse_iterator<const_iterator>