MCPcopy Create free account
hub / github.com/Shannon-Data/ShannonBase / swap

Method swap

include/prealloced_array.h:538–548  ·  view source on GitHub ↗

Exchanges the content of the container by the content of rhs, which is another vector object of the same type. Sizes may differ. We use std::swap to do the operation. */

Source from the content-addressed store, hash-verified

536 We use std::swap to do the operation.
537 */
538 void swap(Prealloced_array &rhs) {
539 // Just swap pointers if both arrays have done malloc.
540 if (!using_inline_buffer() && !rhs.using_inline_buffer()) {
541 std::swap(m_ext.m_alloced_size, rhs.m_ext.m_alloced_size);
542 std::swap(m_ext.m_alloced_capacity, rhs.m_ext.m_alloced_capacity);
543 std::swap(m_ext.m_array_ptr, rhs.m_ext.m_array_ptr);
544 std::swap(m_psi_key, rhs.m_psi_key);
545 return;
546 }
547 std::swap(*this, rhs);
548 }
549
550 /**
551 Requests the container to reduce its capacity to fit its size.

Callers

nothing calls this directly

Calls 2

using_inline_bufferMethod · 0.80
swapFunction · 0.70

Tested by

no test coverage detected