MySQL  8.0.20
Source Code Documentation
prealloced_array.h
Go to the documentation of this file.
1 /* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PREALLOCED_ARRAY_INCLUDED
24 #define PREALLOCED_ARRAY_INCLUDED
25 
26 /**
27  @file include/prealloced_array.h
28 */
29 
30 #include <stddef.h>
31 #include <algorithm>
32 #include <new>
33 #include <type_traits>
34 #include <utility>
35 
36 #include "my_compiler.h"
37 #include "my_dbug.h"
38 #include "my_inttypes.h"
39 #include "my_sys.h"
40 #include "mysql/psi/psi_memory.h"
42 
43 /**
44  A typesafe replacement for DYNAMIC_ARRAY. We do our own memory management,
45  and pre-allocate space for a number of elements. The purpose is to
46  pre-allocate enough elements to cover normal use cases, thus saving
47  malloc()/free() overhead.
48  If we run out of space, we use malloc to allocate more space.
49 
50  The interface is chosen to be similar to std::vector.
51  We keep the std::vector property that storage is contiguous.
52 
53  @remark
54  Unlike DYNAMIC_ARRAY, elements are properly copied
55  (rather than memcpy()d) if the underlying array needs to be expanded.
56 
57  @remark
58  Depending on Has_trivial_destructor, we destroy objects which are
59  removed from the array (including when the array object itself is destroyed).
60 
61  @tparam Element_type The type of the elements of the container.
62  Elements must be copyable or movable.
63  @tparam Prealloc Number of elements to pre-allocate.
64  */
65 template <typename Element_type, size_t Prealloc>
67  /**
68  Is Element_type trivially destructible? If it is, we don't destroy
69  elements when they are removed from the array or when the array is
70  destroyed.
71  */
72  static constexpr bool Has_trivial_destructor =
74 
75  /**
76  Casts the raw buffer to the proper Element_type.
77  We use a raw buffer rather than Element_type[] in order to avoid having
78  CTORs/DTORs invoked by the C++ runtime.
79  */
80  Element_type *cast_rawbuff() {
81  return static_cast<Element_type *>(static_cast<void *>(m_buff));
82  }
83 
84  public:
85  /// Initial capacity of the array.
86  static const size_t initial_capacity = Prealloc;
87 
88  /// Standard typedefs.
89  typedef Element_type value_type;
90  typedef size_t size_type;
91  typedef ptrdiff_t difference_type;
92 
93  typedef Element_type *iterator;
94  typedef const Element_type *const_iterator;
95 
96  explicit Prealloced_array(PSI_memory_key psi_key)
97  : m_size(0),
98  m_capacity(Prealloc),
100  m_psi_key(psi_key) {
101  static_assert(Prealloc != 0, "We do not want a zero-size array.");
102  }
103 
104  /**
105  Initializes (parts of) the array with default values.
106  Using 'Prealloc' for initial_size makes this similar to a raw C array.
107  */
108  Prealloced_array(PSI_memory_key psi_key, size_t initial_size)
109  : m_size(0),
110  m_capacity(Prealloc),
112  m_psi_key(psi_key) {
113  static_assert(Prealloc != 0, "We do not want a zero-size array.");
114 
115  if (initial_size > Prealloc) {
116  // We avoid using reserve() since it requires Element_type to be copyable.
117  void *mem =
118  my_malloc(m_psi_key, initial_size * element_size(), MYF(MY_WME));
119  if (!mem) return;
120  m_array_ptr = static_cast<Element_type *>(mem);
121  m_capacity = initial_size;
122  }
123  for (size_t ix = 0; ix < initial_size; ++ix) {
124  Element_type *p = &m_array_ptr[m_size++];
125  ::new (p) Element_type();
126  }
127  }
128 
129  /**
130  An object instance "owns" its array, so we do deep copy here.
131  */
133  : m_size(0),
134  m_capacity(Prealloc),
136  m_psi_key(that.m_psi_key) {
137  if (this->reserve(that.capacity())) return;
138  for (const Element_type *p = that.begin(); p != that.end(); ++p)
139  this->push_back(*p);
140  }
141 
143  : m_size(0),
144  m_capacity(Prealloc),
146  m_psi_key(that.m_psi_key) {
147  *this = std::move(that);
148  }
149 
150  /**
151  Range constructor.
152 
153  Constructs a container with as many elements as the range [first,last),
154  with each element constructed from its corresponding element in that range,
155  in the same order.
156  */
157  Prealloced_array(PSI_memory_key psi_key, const_iterator first,
158  const_iterator last)
159  : m_size(0),
160  m_capacity(Prealloc),
162  m_psi_key(psi_key) {
163  if (this->reserve(last - first)) return;
164  for (; first != last; ++first) push_back(*first);
165  }
166 
167  /**
168  Copies all the elements from 'that' into this container.
169  Any objects in this container are destroyed first.
170  */
172  this->clear();
173  if (this->reserve(that.capacity())) return *this;
174  for (const Element_type *p = that.begin(); p != that.end(); ++p)
175  this->push_back(*p);
176  return *this;
177  }
178 
180  this->clear();
181  if (that.m_array_ptr != that.cast_rawbuff()) {
183  // The array is on the heap, so we can just grab it.
184  m_array_ptr = that.m_array_ptr;
185  m_capacity = that.m_capacity;
186  m_size = that.m_size;
187  that.m_size = 0;
188  that.m_array_ptr = that.cast_rawbuff();
189  that.m_capacity = Prealloc;
190  } else {
191  // Move over each element.
192  if (this->reserve(that.capacity())) return *this;
193  for (Element_type *p = that.begin(); p != that.end(); ++p)
194  this->push_back(std::move(*p));
195  that.clear();
196  }
197  return *this;
198  }
199 
200  /**
201  Runs DTOR on all elements if needed.
202  Deallocates array if we exceeded the Preallocated amount.
203  */
205  if (!Has_trivial_destructor) {
206  clear();
207  }
209  }
210 
211  size_t capacity() const { return m_capacity; }
212  size_t element_size() const { return sizeof(Element_type); }
213  bool empty() const { return m_size == 0; }
214  size_t size() const { return m_size; }
215 
216  Element_type &at(size_t n) {
217  DBUG_ASSERT(n < size());
218  return m_array_ptr[n];
219  }
220 
221  const Element_type &at(size_t n) const {
222  DBUG_ASSERT(n < size());
223  return m_array_ptr[n];
224  }
225 
226  Element_type &operator[](size_t n) { return at(n); }
227  const Element_type &operator[](size_t n) const { return at(n); }
228 
229  Element_type &back() { return at(size() - 1); }
230  const Element_type &back() const { return at(size() - 1); }
231 
232  Element_type &front() { return at(0); }
233  const Element_type &front() const { return at(0); }
234 
235  /**
236  begin : Returns a pointer to the first element in the array.
237  end : Returns a pointer to the past-the-end element in the array.
238  */
239  iterator begin() { return m_array_ptr; }
240  iterator end() { return m_array_ptr + size(); }
241  const_iterator begin() const { return m_array_ptr; }
242  const_iterator end() const { return m_array_ptr + size(); }
243  /// Returns a constant pointer to the first element in the array.
244  const_iterator cbegin() const { return begin(); }
245  /// Returns a constant pointer to the past-the-end element in the array.
246  const_iterator cend() const { return end(); }
247 
248  /**
249  Assigns a value to an arbitrary element, even where n >= size().
250  The array is extended with default values if necessary.
251  @retval true if out-of-memory, false otherwise.
252  */
253  bool assign_at(size_t n, const value_type &val) {
254  if (n < size()) {
255  at(n) = val;
256  return false;
257  }
258  if (reserve(n + 1)) return true;
259  resize(n);
260  return push_back(val);
261  }
262 
263  /**
264  Reserves space for array elements.
265  Copies (or moves, if possible) over existing elements, in case we
266  are re-expanding the array.
267 
268  @param n number of elements.
269  @retval true if out-of-memory, false otherwise.
270  */
271  bool reserve(size_t n) {
272  if (n <= m_capacity) return false;
273 
274  void *mem = my_malloc(m_psi_key, n * element_size(), MYF(MY_WME));
275  if (!mem) return true;
276  Element_type *new_array = static_cast<Element_type *>(mem);
277 
278  // Move all the existing elements into the new array.
279  for (size_t ix = 0; ix < m_size; ++ix) {
280  Element_type *new_p = &new_array[ix];
281  Element_type &old_p = m_array_ptr[ix];
282  ::new (new_p) Element_type(std::move(old_p)); // Move into new location.
283  if (!Has_trivial_destructor)
284  old_p.~Element_type(); // Destroy the old element.
285  }
286 
288 
289  // Forget the old array;
290  m_array_ptr = new_array;
291  m_capacity = n;
292  return false;
293  }
294 
295  /**
296  Copies an element into the back of the array.
297  Complexity: Constant (amortized time, reallocation may happen).
298  @return true if out-of-memory, false otherwise
299  */
300  bool push_back(const Element_type &element) { return emplace_back(element); }
301 
302  /**
303  Copies (or moves, if possible) an element into the back of the array.
304  Complexity: Constant (amortized time, reallocation may happen).
305  @return true if out-of-memory, false otherwise
306  */
307  bool push_back(Element_type &&element) {
308  return emplace_back(std::move(element));
309  }
310 
311  /**
312  Constructs an element at the back of the array.
313  Complexity: Constant (amortized time, reallocation may happen).
314  @return true if out-of-memory, false otherwise
315  */
316  template <typename... Args>
317  bool emplace_back(Args &&... args) {
318  const size_t expansion_factor = 2;
319  if (m_size == m_capacity && reserve(m_capacity * expansion_factor))
320  return true;
321  Element_type *p = &m_array_ptr[m_size++];
322  ::new (p) Element_type(std::forward<Args>(args)...);
323  return false;
324  }
325 
326  /**
327  Removes the last element in the array, effectively reducing the
328  container size by one. This destroys the removed element.
329  */
330  void pop_back() {
331  DBUG_ASSERT(!empty());
332  if (!Has_trivial_destructor) back().~Element_type();
333  m_size -= 1;
334  }
335 
336  /**
337  The array is extended by inserting a new element before the element at the
338  specified position.
339 
340  This is generally an inefficient operation, since we need to copy
341  elements to make a new "hole" in the array.
342 
343  We use std::rotate to move objects, hence Element_type must be
344  move-assignable and move-constructible.
345 
346  @return an iterator pointing to the inserted value
347  */
348  iterator insert(const_iterator position, const value_type &val) {
349  return emplace(position, val);
350  }
351 
352  /**
353  The array is extended by inserting a new element before the element at the
354  specified position. The element is moved into the array, if possible.
355 
356  This is generally an inefficient operation, since we need to copy
357  elements to make a new "hole" in the array.
358 
359  We use std::rotate to move objects, hence Element_type must be
360  move-assignable and move-constructible.
361 
362  @return an iterator pointing to the inserted value
363  */
364  iterator insert(const_iterator position, value_type &&val) {
365  return emplace(position, std::move(val));
366  }
367 
368  /**
369  The array is extended by inserting a new element before the element at the
370  specified position. The element is constructed in-place.
371 
372  This is generally an inefficient operation, since we need to copy
373  elements to make a new "hole" in the array.
374 
375  We use std::rotate to move objects, hence Element_type must be
376  move-assignable and move-constructible.
377 
378  @return an iterator pointing to the inserted value
379  */
380  template <typename... Args>
381  iterator emplace(const_iterator position, Args &&... args) {
382  const difference_type n = position - begin();
383  emplace_back(std::forward<Args>(args)...);
384  std::rotate(begin() + n, end() - 1, end());
385  return begin() + n;
386  }
387 
388  /**
389  Similar to std::set<>::insert()
390  Extends the array by inserting a new element, but only if it cannot be found
391  in the array already.
392 
393  Assumes that the array is sorted with std::less<Element_type>
394  Insertion using this function will maintain order.
395 
396  @retval A pair, with its member pair::first set an iterator pointing to
397  either the newly inserted element, or to the equivalent element
398  already in the array. The pair::second element is set to true if
399  the new element was inserted, or false if an equivalent element
400  already existed.
401  */
402  std::pair<iterator, bool> insert_unique(const value_type &val) {
403  std::pair<iterator, iterator> p = std::equal_range(begin(), end(), val);
404  // p.first == p.second means we did not find it.
405  if (p.first == p.second) return std::make_pair(insert(p.first, val), true);
406  return std::make_pair(p.first, false);
407  }
408 
409  /**
410  Similar to std::set<>::erase()
411  Removes a single element from the array by value.
412  The removed element is destroyed.
413  This effectively reduces the container size by one.
414 
415  This is generally an inefficient operation, since we need to copy
416  elements to fill the "hole" in the array.
417 
418  Assumes that the array is sorted with std::less<Element_type>.
419 
420  @retval number of elements removed, 0 or 1.
421  */
422  size_type erase_unique(const value_type &val) {
423  std::pair<iterator, iterator> p = std::equal_range(begin(), end(), val);
424  if (p.first == p.second) return 0; // Not found
425  erase(p.first);
426  return 1;
427  }
428 
429  /**
430  Similar to std::set<>::count()
431 
432  @note Assumes that array is maintained with insert_unique/erase_unique.
433 
434  @retval 1 if element is found, 0 otherwise.
435  */
436  size_type count_unique(const value_type &val) const {
437  return std::binary_search(begin(), end(), val);
438  }
439 
440  /**
441  Removes a single element from the array.
442  The removed element is destroyed.
443  This effectively reduces the container size by one.
444 
445  This is generally an inefficient operation, since we need to move
446  or copy elements to fill the "hole" in the array.
447 
448  We use std::move to move objects, hence Element_type must be
449  move-assignable.
450  */
451  iterator erase(const_iterator position) {
452  DBUG_ASSERT(position != end());
453  return erase(position - begin());
454  }
455 
456  /**
457  Removes a single element from the array.
458  */
459  iterator erase(size_t ix) {
460  DBUG_ASSERT(ix < size());
461  iterator pos = begin() + ix;
462  if (pos + 1 != end()) std::move(pos + 1, end(), pos);
463  pop_back();
464  return pos;
465  }
466 
467  /**
468  Removes tail elements from the array.
469  The removed elements are destroyed.
470  This effectively reduces the containers size by 'end() - first'.
471  */
472  void erase_at_end(const_iterator first) {
473  const_iterator last = cend();
474  const difference_type diff = last - first;
475  if (!Has_trivial_destructor) {
476  for (; first != last; ++first) first->~Element_type();
477  }
478  m_size -= diff;
479  }
480 
481  /**
482  Removes a range of elements from the array.
483  The removed elements are destroyed.
484  This effectively reduces the containers size by 'last - first'.
485 
486  This is generally an inefficient operation, since we need to move
487  or copy elements to fill the "hole" in the array.
488 
489  We use std::move to move objects, hence Element_type must be
490  move-assignable.
491  */
492  iterator erase(const_iterator first, const_iterator last) {
493  /*
494  std::move() wants non-const input iterators, otherwise it cannot move and
495  must always copy the elements. Convert first and last from const_iterator
496  to iterator.
497  */
498  iterator start = begin() + (first - cbegin());
499  iterator stop = begin() + (last - cbegin());
500  if (first != last) erase_at_end(std::move(stop, end(), start));
501  return start;
502  }
503 
504  /**
505  Exchanges the content of the container by the content of rhs, which
506  is another vector object of the same type. Sizes may differ.
507 
508  We use std::swap to do the operation.
509  */
510  void swap(Prealloced_array &rhs) {
511  // Just swap pointers if both arrays have done malloc.
512  if (m_array_ptr != cast_rawbuff() &&
513  rhs.m_array_ptr != rhs.cast_rawbuff()) {
514  std::swap(m_size, rhs.m_size);
518  return;
519  }
520  std::swap(*this, rhs);
521  }
522 
523  /**
524  Requests the container to reduce its capacity to fit its size.
525  */
526  void shrink_to_fit() {
527  // Cannot shrink the pre-allocated array.
528  if (m_array_ptr == cast_rawbuff()) return;
529  // No point in swapping.
530  if (size() == capacity()) return;
531  Prealloced_array tmp(m_psi_key, begin(), end());
532  if (size() <= Prealloc) {
533  /*
534  The elements fit in the pre-allocated array. Destruct the
535  heap-allocated array in this, and copy the elements into the
536  pre-allocated array.
537  */
538  this->~Prealloced_array();
539  new (this) Prealloced_array(tmp.m_psi_key, tmp.begin(), tmp.end());
540  } else {
541  // Both this and tmp have a heap-allocated array. Swap pointers.
542  swap(tmp);
543  }
544  }
545 
546  /**
547  Resizes the container so that it contains n elements.
548 
549  If n is smaller than the current container size, the content is
550  reduced to its first n elements, removing those beyond (and
551  destroying them).
552 
553  If n is greater than the current container size, the content is
554  expanded by inserting at the end as many elements as needed to
555  reach a size of n. If val is specified, the new elements are
556  initialized as copies of val, otherwise, they are
557  value-initialized.
558 
559  If n is also greater than the current container capacity, an automatic
560  reallocation of the allocated storage space takes place.
561 
562  Notice that this function changes the actual content of the
563  container by inserting or erasing elements from it.
564  */
565  void resize(size_t n, const Element_type &val = Element_type()) {
566  if (n == m_size) return;
567  if (n > m_size) {
568  if (!reserve(n)) {
569  while (n != m_size) push_back(val);
570  }
571  return;
572  }
573  if (!Has_trivial_destructor) {
574  while (n != m_size) pop_back();
575  }
576  m_size = n;
577  }
578 
579  /**
580  Removes (and destroys) all elements.
581  Does not change capacity.
582  */
583  void clear() {
584  if (!Has_trivial_destructor) {
585  for (Element_type *p = begin(); p != end(); ++p)
586  p->~Element_type(); // Destroy discarded element.
587  }
588  m_size = 0;
589  }
590 
591  private:
592  size_t m_size;
593  size_t m_capacity;
594  // This buffer must be properly aligned.
595  alignas(Element_type) char m_buff[Prealloc * sizeof(Element_type)];
596  Element_type *m_array_ptr;
598 };
599 
600 #endif // PREALLOCED_ARRAY_INCLUDED
size_t capacity() const
Definition: prealloced_array.h:211
const Element_type & operator[](size_t n) const
Definition: prealloced_array.h:227
void resize(size_t n, const Element_type &val=Element_type())
Resizes the container so that it contains n elements.
Definition: prealloced_array.h:565
Element_type * m_array_ptr
Definition: prealloced_array.h:596
iterator erase(size_t ix)
Removes a single element from the array.
Definition: prealloced_array.h:459
#define MY_WME
Definition: my_sys.h:116
Some integer typedefs for easier portability.
Element_type & at(size_t n)
Definition: prealloced_array.h:216
std::pair< iterator, bool > insert_unique(const value_type &val)
Similar to std::set<>::insert() Extends the array by inserting a new element, but only if it cannot b...
Definition: prealloced_array.h:402
Prealloced_array & operator=(const Prealloced_array &that)
Copies all the elements from &#39;that&#39; into this container.
Definition: prealloced_array.h:171
void erase_at_end(const_iterator first)
Removes tail elements from the array.
Definition: prealloced_array.h:472
Prealloced_array(PSI_memory_key psi_key, const_iterator first, const_iterator last)
Range constructor.
Definition: prealloced_array.h:157
Element_type & front()
Definition: prealloced_array.h:232
bool empty() const
Definition: prealloced_array.h:213
const Element_type & back() const
Definition: prealloced_array.h:230
void shrink_to_fit()
Requests the container to reduce its capacity to fit its size.
Definition: prealloced_array.h:526
iterator emplace(const_iterator position, Args &&... args)
The array is extended by inserting a new element before the element at the specified position...
Definition: prealloced_array.h:381
const_iterator begin() const
Definition: prealloced_array.h:241
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
const_iterator end() const
Definition: prealloced_array.h:242
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:46
size_type erase_unique(const value_type &val)
Similar to std::set<>::erase() Removes a single element from the array by value.
Definition: prealloced_array.h:422
static const size_t initial_capacity
Initial capacity of the array.
Definition: prealloced_array.h:86
static MEM_ROOT mem
Definition: sql_servers.cc:97
Prealloced_array(const Prealloced_array &that)
An object instance "owns" its array, so we do deep copy here.
Definition: prealloced_array.h:132
ptrdiff_t difference_type
Definition: prealloced_array.h:91
Prealloced_array(Prealloced_array &&that)
Definition: prealloced_array.h:142
iterator begin()
begin : Returns a pointer to the first element in the array.
Definition: prealloced_array.h:239
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1089
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:66
const Element_type & front() const
Definition: prealloced_array.h:233
#define DBUG_ASSERT(A)
Definition: my_dbug.h:199
static void stop(PluginFuncEnv *)
Definition: rest_mock_server.cc:277
size_t size() const
Definition: prealloced_array.h:214
bool emplace_back(Args &&... args)
Constructs an element at the back of the array.
Definition: prealloced_array.h:317
bool assign_at(size_t n, const value_type &val)
Assigns a value to an arbitrary element, even where n >= size().
Definition: prealloced_array.h:253
char * pos
Definition: do_ctype.cc:76
#define MYF(v)
Element_type & back()
Definition: prealloced_array.h:229
Prealloced_array & operator=(Prealloced_array &&that)
Definition: prealloced_array.h:179
const Element_type * const_iterator
Definition: prealloced_array.h:94
iterator insert(const_iterator position, value_type &&val)
The array is extended by inserting a new element before the element at the specified position...
Definition: prealloced_array.h:364
Element_type * cast_rawbuff()
Casts the raw buffer to the proper Element_type.
Definition: prealloced_array.h:80
const_iterator cend() const
Returns a constant pointer to the past-the-end element in the array.
Definition: prealloced_array.h:246
Prealloced_array(PSI_memory_key psi_key)
Definition: prealloced_array.h:96
Header for compiler-dependent features.
char m_buff[Prealloc *sizeof(Element_type)]
Definition: prealloced_array.h:595
void pop_back()
Removes the last element in the array, effectively reducing the container size by one...
Definition: prealloced_array.h:330
iterator end()
Definition: prealloced_array.h:240
size_t size_type
Definition: prealloced_array.h:90
Common header for many mysys elements.
const Element_type & at(size_t n) const
Definition: prealloced_array.h:221
iterator erase(const_iterator first, const_iterator last)
Removes a range of elements from the array.
Definition: prealloced_array.h:492
int n
Definition: xcom_base.c:425
bool push_back(Element_type &&element)
Copies (or moves, if possible) an element into the back of the array.
Definition: prealloced_array.h:307
PSI_memory_key m_psi_key
Definition: prealloced_array.h:597
~Prealloced_array()
Runs DTOR on all elements if needed.
Definition: prealloced_array.h:204
Performance schema instrumentation interface.
size_type count_unique(const value_type &val) const
Similar to std::set<>::count()
Definition: prealloced_array.h:436
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:583
Prealloced_array(PSI_memory_key psi_key, size_t initial_size)
Initializes (parts of) the array with default values.
Definition: prealloced_array.h:108
size_t m_capacity
Definition: prealloced_array.h:593
Element_type & operator[](size_t n)
Definition: prealloced_array.h:226
size_t element_size() const
Definition: prealloced_array.h:212
const_iterator cbegin() const
Returns a constant pointer to the first element in the array.
Definition: prealloced_array.h:244
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:606
iterator insert(const_iterator position, const value_type &val)
The array is extended by inserting a new element before the element at the specified position...
Definition: prealloced_array.h:348
iterator erase(const_iterator position)
Removes a single element from the array.
Definition: prealloced_array.h:451
const char * p
Definition: ctype-mb.cc:1235
const string value("\alue\)
bool push_back(const Element_type &element)
Copies an element into the back of the array.
Definition: prealloced_array.h:300
Element_type value_type
Standard typedefs.
Definition: prealloced_array.h:89
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Below functions are used by the components.
Definition: my_memory.cc:57
Element_type * iterator
Definition: prealloced_array.h:93
static constexpr bool Has_trivial_destructor
Is Element_type trivially destructible? If it is, we don&#39;t destroy elements when they are removed fro...
Definition: prealloced_array.h:72
bool reserve(size_t n)
Reserves space for array elements.
Definition: prealloced_array.h:271
size_t m_size
Definition: prealloced_array.h:592
void swap(Prealloced_array &rhs)
Exchanges the content of the container by the content of rhs, which is another vector object of the s...
Definition: prealloced_array.h:510
static void start(PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:165