MySQL 9.1.0
Source Code Documentation
|
A typesafe replacement for DYNAMIC_ARRAY. More...
#include <mem_root_array.h>
Public Types | |
typedef Element_type | value_type |
Convenience typedef, same typedef name as std::vector. More... | |
typedef Element_type * | iterator |
Random access iterators to value_type and const value_type. More... | |
typedef const Element_type * | const_iterator |
Public Member Functions | |
void | init (MEM_ROOT *root) |
void | init_empty_const () |
Initialize empty array that we aren't going to grow. More... | |
Element_type * | data () |
const Element_type * | data () const |
Element_type & | at (size_t n) |
const Element_type & | at (size_t n) const |
Element_type & | operator[] (size_t n) |
const Element_type & | operator[] (size_t n) const |
Element_type & | back () |
const Element_type & | back () const |
Element_type * | begin () |
Returns a pointer to the first element in the array. More... | |
const Element_type * | begin () const |
Element_type * | end () |
Returns a pointer to the past-the-end element in the array. More... | |
const Element_type * | end () const |
const_iterator | cbegin () const |
Returns a constant pointer to the first element in the array. More... | |
const_iterator | cend () const |
Returns a constant pointer to the past-the-end element in the array. More... | |
void | clear () |
Erases all of the elements. More... | |
void | chop (const size_t pos) |
Chops the tail off the array, erasing all tail elements. More... | |
bool | reserve (size_t n) |
Reserves space for array elements. More... | |
bool | push_back (const Element_type &element) |
Adds a new element at the end of the array, after its current last element. More... | |
bool | push_back (Element_type &&element) |
Adds a new element at the end of the array, after its current last element. More... | |
template<typename... Args> | |
bool | emplace_back (Args &&...args) |
Constructs an element at the back of the array in-place. More... | |
bool | push_front (const Element_type &element) |
Adds a new element at the beginning of the array. More... | |
bool | push_front (Element_type &&element) |
Adds a new element at the front of the array. More... | |
void | pop_back () |
Removes the last element in the array, effectively reducing the container size by one. More... | |
void | resize (size_t n, const value_type &val) |
Resizes the container so that it contains n elements. More... | |
void | resize (size_t n) |
Same as resize(size_t, const value_type &val), but default-constructs the new elements. More... | |
iterator | erase (const_iterator first, const_iterator last) |
Erase all the elements in the specified range. More... | |
iterator | erase (const_iterator position) |
Removes a single element from the array. More... | |
iterator | erase (size_t ix) |
Removes a single element from the array. More... | |
iterator | insert (const_iterator pos, const Element_type &value) |
Insert an element at a given position. More... | |
size_t | erase_value (const value_type &val) |
Removes a single element from the array by value. More... | |
iterator | erase (iterator position) |
Removes a single element from the array. More... | |
size_t | capacity () const |
size_t | element_size () const |
bool | empty () const |
size_t | size () const |
Protected Attributes | |
MEM_ROOT * | m_root |
Element_type * | m_array |
size_t | m_size |
size_t | m_capacity |
Static Private Attributes | |
static constexpr bool | has_trivial_destructor |
Is Element_type trivially destructible? If it is, we don't destroy elements when they are removed from the array or when the array is destroyed. More... | |
A typesafe replacement for DYNAMIC_ARRAY.
We use MEM_ROOT for allocating storage, rather than the C++ heap. The interface is chosen to be similar to std::vector.
Element_type | The type of the elements of the container. Elements must be copyable. |
typedef const Element_type* Mem_root_array_YY< Element_type >::const_iterator |
typedef Element_type* Mem_root_array_YY< Element_type >::iterator |
Random access iterators to value_type and const value_type.
typedef Element_type Mem_root_array_YY< Element_type >::value_type |
Convenience typedef, same typedef name as std::vector.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns a pointer to the first element in the array.
|
inline |
|
inline |
|
inline |
Returns a constant pointer to the first element in the array.
|
inline |
Returns a constant pointer to the past-the-end element in the array.
|
inline |
Chops the tail off the array, erasing all tail elements.
pos | Index of first element to erase. |
|
inline |
Erases all of the elements.
|
inline |
|
inline |
|
inline |
|
inline |
Constructs an element at the back of the array in-place.
args | Arguments to pass to the constructor. |
|
inline |
|
inline |
Returns a pointer to the past-the-end element in the array.
|
inline |
|
inline |
Erase all the elements in the specified range.
first | iterator that points to the first element to remove |
last | iterator that points to the element after the last one to remove |
|
inline |
Removes a single element from the array.
position | iterator that points to the element to remove |
|
inline |
Removes a single element from the array.
The removed element is destroyed. This effectively reduces the container size by one.
This is generally an inefficient operation, since we need to copy elements to fill the "hole" in the array.
We use std::copy to move objects, hence Element_type must be assignable.
|
inline |
Removes a single element from the array.
ix | zero-based number of the element to remove |
|
inline |
Removes a single element from the array by value.
The removed element is destroyed. This effectively reduces the container size by one. Note that if there are multiple elements having the same value, only the first element is removed.
This is generally an inefficient operation, since we need to copy elements to fill the "hole" in the array.
We use std::copy to move objects, hence Element_type must be assignable.
number | of elements removed, 0 or 1. |
|
inline |
|
inline |
Initialize empty array that we aren't going to grow.
|
inline |
Insert an element at a given position.
pos | the new element is inserted before the element at this position |
value | the value of the new element |
|
inline |
|
inline |
|
inline |
Removes the last element in the array, effectively reducing the container size by one.
This destroys the removed element.
|
inline |
Adds a new element at the end of the array, after its current last element.
The content of this new element is initialized to a copy of the input argument.
element | Object to copy. |
true | if out-of-memory, false otherwise. |
|
inline |
Adds a new element at the end of the array, after its current last element.
The content of this new element is initialized by moving the input element.
element | Object to move. |
true | if out-of-memory, false otherwise. |
|
inline |
Adds a new element at the beginning of the array.
The content of this new element is initialized to a copy of the input argument.
element | Object to copy. |
true | if out-of-memory, false otherwise. |
|
inline |
Adds a new element at the front of the array.
The content of this new element is initialized by moving the input element.
element | Object to move. |
true | if out-of-memory, false otherwise. |
|
inline |
Reserves space for array elements.
Copies over existing elements, in case we are re-expanding the array.
n | number of elements. |
true | if out-of-memory, false otherwise. |
|
inline |
Same as resize(size_t, const value_type &val), but default-constructs the new elements.
This allows one to resize containers even if value_type is not copy-constructible.
|
inline |
Resizes the container so that it contains n elements.
If n is smaller than the current container size, the content is reduced to its first n elements, removing those beyond (and destroying them).
If n is greater than the current container size, the content is expanded by inserting at the end as many elements as needed to reach a size of n. If val is specified, the new elements are initialized as copies of val, otherwise, they are value-initialized.
If n is also greater than the current container capacity, an automatic reallocation of the allocated storage space takes place.
Notice that this function changes the actual content of the container by inserting or erasing elements from it.
|
inline |
|
staticconstexprprivate |
Is Element_type trivially destructible? If it is, we don't destroy elements when they are removed from the array or when the array is destroyed.
|
protected |
|
protected |
|
protected |
|
protected |