absl::InlinedVector

A drop-in replacement for std::vector that stores small sequences inline.

Synopsis

Declared in <absl/container/inlined_vector.h>

template<
    typename T,
    size_t N,
    typename A = std::allocator<T>>
class InlinedVector;

Description

An absl::InlinedVector is designed to be a drop-in replacement for std::vector for use cases where the vector's size is sufficiently small that it can be inlined. If the inlined vector does grow beyond its estimated capacity, it will trigger an initial allocation on the heap, and will behave as a std::vector. The API of the absl::InlinedVector within this file is designed to cover the same API footprint as covered by std::vector.

Type Aliases

NameDescription
allocator_type The allocator type used by the inlined vector.
const_iterator A const iterator over the elements.
const_pointer A pointer to a const element.
const_reference A reference to a const element.
const_reverse_iterator A const reverse iterator over the elements.
difference_type A signed integral type used for differences between iterators.
iterator An iterator over the elements.
pointer A pointer to an element.
reference A reference to an element.
reverse_iterator A reverse iterator over the elements.
size_type An unsigned integral type used for sizes.
value_type The type of the elements stored in the inlined vector.

Member Functions

NameDescription
InlinedVector [constructor]Constructors
~InlinedVector [destructor]Destroys the inlined vector and its elements.
operator= Assignment operators
assign assign overloads
at at overloads
back back overloads
begin begin overloads
capacity Returns the number of elements that could be stored in the inlined vector without requiring a reallocation.
cbegin Returns a const_iterator to the beginning of the inlined vector.
cend Returns a const_iterator to the end of the inlined vector.
clear Destroys all elements in the inlined vector, setting the size to 0 and preserving capacity.
crbegin Returns a const_reverse_iterator from the end of the inlined vector.
crend Returns a const_reverse_iterator from the beginning of the inlined vector.
data data overloads
emplace Constructs and inserts an element using args... in the inlined vector at pos, returning an iterator pointing to the newly emplaced element.
emplace_back Constructs and inserts an element using args... in the inlined vector at end(), returning a reference to the newly emplaced element.
empty Returns whether the inlined vector contains no elements.
end end overloads
erase erase overloads
front front overloads
get_allocator Returns a copy of the inlined vector's allocator.
insert insert overloads
max_size Returns the maximum number of elements the inlined vector can hold.
operator[] Subscript operators
pop_back Destroys the element at back(), reducing the size by 1.
push_back push_back overloads
rbegin rbegin overloads
rend rend overloads
reserve Ensures that there is enough room for at least n elements.
resize resize overloads
shrink_to_fit Attempts to reduce memory usage by moving elements to (or keeping elements in) the smallest available buffer sufficient for containing size() elements.
size Returns the number of elements in the inlined vector.
swap Swaps the contents of the inlined vector with other.

Friends

NameDescription
absl::AbslHashValueProvides absl::Hash support for absl::InlinedVector.

Non-Member Functions

NameDescription
erase_ifErases all elements that satisfy the predicate pred from the inlined vector v.
operator!=Tests for value-inequality of two inlined vectors.
operator<Tests whether the value of an inlined vector is less than the value of another inlined vector using a lexicographical comparison algorithm.
operator<=Tests whether the value of an inlined vector is less than or equal to the value of another inlined vector using a lexicographical comparison algorithm.
operator==Tests for value-equality of two inlined vectors.
operator>Tests whether the value of an inlined vector is greater than the value of another inlined vector using a lexicographical comparison algorithm.
operator>=Tests whether the value of an inlined vector is greater than or equal to the value of another inlined vector using a lexicographical comparison algorithm.
swapSwaps the contents of two inlined vectors.