small_vector

The APIs described in this section are reserved and may be changed or deprecated in the future. They do not need your attention.

Table 1 API list

API Definition

Description

PtrToValue(const void *const ptr)

Converts the void* type to the uint64_t type.

ValueToPtr(const uint64_t value)

Converts the uint64_t type to the void* type.

VPtrToValue(const std::vector<void *> v_ptr)

Converts a void* element in the vector container to a uint64_t element.

PtrToPtr(TI *const ptr)

Converts a pointer variable of any type (the pointer address cannot be changed) to another pointer variable of any type.

PtrToPtr(const TI *const ptr)

Converts a pointer variable of any type (the pointer address and value cannot be changed) to another pointer variable of any type (the pointer value cannot be changed).

PtrAdd(T *const ptr, const size_t max_buf_len, const size_t idx)

When the pointer variable ptr is not null and idx is less than max_buf_len, the pointer obtained by adding the length of idx to the pointer address ptr is returned. Otherwise, null is returned.

SmallVector(const allocator_type &alloc = Alloc())

Indicates the default constructor of SmallVector.

SmallVector(const size_type count, const T &value, const allocator_type &alloc = Alloc())

Indicates the SmallVector constructor, which initializes count elements to have the same value.

SmallVector(const size_type count, const allocator_type &alloc = Alloc())

Indicates the SmallVector constructor with count initial elements.

SmallVector(InputIt first, const InputIt last, const allocator_type &alloc = Alloc())

Indicates the SmallVector constructor, which uses the iterator range to initialize elements.

SmallVector(const SmallVector &other)

Copies elements in other to new memory.

SmallVector(SmallVector &&other)

Moves an existing vector object to a newly created vector.

SmallVector(const std::initializer_list<T> init, const allocator_type &alloc = Alloc())

Indicates the SmallVector constructor.

clear()

Clears the entire SmallVector.

ClearElements()

Clears the entire SmallVector and returns the initial address of the iterator.

FreeStorage()

Clears the memory.

at(const size_type index)

Returns the reference to the element at the index position in the SmallVector.

front()

Returns the reference to the first element in the SmallVector.

begin()

Returns an iterator, which points to the first element in the SmallVector container.

back()

Returns the reference to the last element in the SmallVector.

rbegin()

Returns a reverse iterator, which points to the last element in the SmallVector container.

data()

Returns the pointer to the first element.

GetPointer()

Returns the pointer to the first element.

cbegin()

Returns a const_iterator, which points to the first element in the SmallVector container.

cend()

Returns a const_iterator, which points to the next element of the last element in the SmallVector container.

crbegin()

Returns a const_iterator, which points to the last element in the SmallVector container.

rend()

Returns a reverse iterator, which points to the element before the first element in the SmallVector container. This element is considered to be its reverse end.

crend()

Returns a const reverse iterator, which points to the element before the first element in the SmallVector container. This element is considered to be its reverse end.

size()

Returns the number of elements in the SmallVector container.

reserve(const size_type new_cap)

If new_cap is greater than the allocated capacity, the container capacity should be changed. new_cap must suffice to hold the elements of capacity().

capacity()

Indicates the size of the allocated capacity.

insert(const_iterator const pos, const T &value)

Inserts an element before the specified position in the SmallVector container.

insert(const_iterator const pos, T &&value)

Inserts a value element before the specified position in the SmallVector container.

insert(const_iterator const pos, const size_type count, const T &value)

Inserts count elements with value before the specified position in the SmallVector container.

insert(const_iterator const pos, const InputIt first, const InputIt last)

Copies and inserts elements in the specified range [first, last) before the specified position in the SmallVector container.

insert(const_iterator const pos, const std::initializer_list<T> value_list)

Inserts all elements of a T-type object array before the specified position in the SmallVector container.

emplace(const_iterator const pos, Args &&...args)

Inserts a new element before pos in the SmallVector container. This element is constructed using args.

erase(const_iterator const pos)

Deletes an element from a specified position in a SmallVector container.

erase(const_iterator const first, const_iterator const last)

Deletes elements in the specified range [first, last) from the SmallVector container.

push_back(const T &value)

Adds an element to the end of the SmallVector container.

push_back(T &&value)

Adds the value element to the end of the SmallVector container.

emplace_back(Args &&...args)

Inserts an element at the end of the SmallVector container. This element is constructed using args.

pop_back()

Deletes the last element of the SmallVector container.

resize(const size_type count)

Changes the size of the SmallVector container to count. If count is smaller than the current container size, the first count elements are used. Otherwise, the default constructor is used to add elements to the end of the container.

resize(const size_type count, const T &value)

Changes the size of the SmallVector container to count. If count is smaller than the current container size, the first count elements are used. Otherwise, value is copied to the added elements.

swap(SmallVector &other)

Swaps the content of the SmallVector container with that of the other SmallVector container.

GetPointer(const size_type idx = 0UL)

Returns the address of a specified position.

InitStorage(const size_type size)

Initializes the memory of the entire container. If size is less than the current capacity, the memory of the current capacity is initialized. If size is greater than the current capacity, the container is resized to size before the memory is initialized.

CopyRange(T *iter, InputIt first, const InputIt last)

Copies the memory in the range [first, last) to the iter position.

MoveFrom(SmallVector &other)

Copies the memory from the other container to the current container.

CheckOutOfRange(const size_type index)

Checks whether the index exceeds the container range.

ExpandCap(const size_type range_begin, const size_type range_len)

Allocates a new memory, whose size is the original container capacity plus the value of range_len. If the new memory is less than twice the original capacity, expand the memory by twice. Expand the memory of range_len size at the range_begin position of the original SmallVector container, copy the memory to the new memory, and free the memory of the original container.

ExpandSize(const size_type range_begin, const size_type range_len)

Expands the memory of range_len size at the range_begin position in the SmallVector container.

Expand(const size_type range_begin, const size_type range_len)

Expands the memory of the SmallVector container. If the expanded memory is greater than the maximum capacity of the container, expand the memory based on ExpandCap. Otherwise, expand the memory based on ExpandSize.

Shrink(const size_type range_begin, const size_type range_end)

Deletes the memory between range_begin and range_end in the SmartVector container.

swap(op::internal::SmallVector<T, N, Alloc> &sv1, op::internal::SmallVector<T, N, Alloc> &sv2)

Swaps the elements of two SmallVector containers sv1 and sv2.