NCBI C++ ToolKit
|
Search Toolkit Book for bm::byte_buffer
Byte buffer template, extention of byte_buffer_ptr memory management. More...
#include <util/bitset/bmbuffer.h>
Public Types | |
typedef BVAlloc | bv_allocator_type |
typedef bv_allocator_type::block_allocator_type | allocator_type |
typedef size_t | size_type |
Public Member Functions | |
byte_buffer () noexcept | |
byte_buffer (size_t in_capacity) | |
byte_buffer (const byte_buffer &lhs) | |
byte_buffer (byte_buffer &&in_buf) noexcept | |
Move constructor. More... | |
byte_buffer & | operator= (byte_buffer &&lhs) noexcept |
Move assignment operator. More... | |
byte_buffer & | operator= (const byte_buffer &lhs) |
~byte_buffer () | |
void | swap (byte_buffer &other) noexcept |
swap content with another buffer More... | |
void | move_from (byte_buffer &other) noexcept |
take/move content from another buffer More... | |
void | release () |
Free underlying memory. More... | |
void | copy_from (const unsigned char *in_buf, size_t in_size) |
copy data from an external buffer More... | |
size_t | capacity () const noexcept |
Get buffer capacity. More... | |
unsigned char * | resize (size_t new_size, bool copy_content=true) |
adjust current size (buffer content preserved) More... | |
void | resize_no_check (size_t new_size) noexcept |
adjust current size (no need to reallocate) More... | |
void | reserve (size_t new_capacity) |
reserve new capacity (buffer content preserved) More... | |
void | reinit (size_t new_capacity) |
reserve new capacity (buffer content NOT preserved, size set to 0) More... | |
void | reallocate (size_t new_capacity) |
reserve new capacity (buffer content NOT preserved, size set to 0) More... | |
void | optimize () |
try to shrink the capacity to more optimal size More... | |
size_t | mem_usage () const noexcept |
return memory consumtion More... | |
void | free_buffer () |
Free mmemory. More... | |
Public Member Functions inherited from bm::byte_buffer_ptr | |
byte_buffer_ptr () noexcept | |
byte_buffer_ptr (unsigned char *in_buf, size_t in_size) noexcept | |
construct byte buffer pointer More... | |
void | set_buf (unsigned char *in_buf, size_t in_size) noexcept |
Set buffer pointer. More... | |
size_t | size () const noexcept |
Get buffer size. More... | |
const unsigned char * | buf () const noexcept |
Get read access to buffer memory. More... | |
unsigned char * | data () noexcept |
Get write access to buffer memory. More... | |
const unsigned char * | data () const noexcept |
const access to buffer memory More... | |
bool | operator== (const byte_buffer_ptr &lhs) const noexcept |
bool | equal (const byte_buffer_ptr &lhs) const noexcept |
return true if content and size is the same More... | |
Private Member Functions | |
void | set_buf (unsigned char *buf, size_t size) |
Override from the base class. More... | |
void | allocate (size_t new_capacity) |
Static Private Member Functions | |
static size_t | compute_words (size_t capacity) noexcept |
compute number of words for the desired capacity More... | |
Private Attributes | |
size_t | capacity_ |
current capacity More... | |
size_t | alloc_factor_ |
number of blocks allocated for buffer More... | |
Additional Inherited Members | |
Protected Attributes inherited from bm::byte_buffer_ptr | |
unsigned char * | byte_buf_ |
byte buffer pointer to hold data More... | |
size_t | size_ |
current buffer size More... | |
Byte buffer template, extention of byte_buffer_ptr memory management.
Definition at line 89 of file bmbuffer.h.
typedef bv_allocator_type::block_allocator_type bm::byte_buffer< BVAlloc >::allocator_type |
Definition at line 93 of file bmbuffer.h.
typedef BVAlloc bm::byte_buffer< BVAlloc >::bv_allocator_type |
Definition at line 92 of file bmbuffer.h.
typedef size_t bm::byte_buffer< BVAlloc >::size_type |
Definition at line 94 of file bmbuffer.h.
|
inlinenoexcept |
Definition at line 97 of file bmbuffer.h.
|
inline |
Definition at line 100 of file bmbuffer.h.
|
inline |
Definition at line 106 of file bmbuffer.h.
|
inlinenoexcept |
Move constructor.
Definition at line 117 of file bmbuffer.h.
|
inline |
Definition at line 144 of file bmbuffer.h.
|
inlineprivate |
Definition at line 296 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::byte_buffer(), bm::byte_buffer< bv_allocator_type >::copy_from(), bm::byte_buffer< bv_allocator_type >::reinit(), and bm::byte_buffer< bv_allocator_type >::reserve().
|
inlinenoexcept |
Get buffer capacity.
Definition at line 197 of file bmbuffer.h.
Referenced by bm::heap_vector< const bm::word_t *, allocator_type, true >::capacity(), bm::byte_buffer< bv_allocator_type >::compute_words(), bm::byte_buffer< bv_allocator_type >::mem_usage(), and SerializationBufferTest().
|
inlinestaticprivatenoexcept |
compute number of words for the desired capacity
Definition at line 290 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::allocate(), and bm::byte_buffer< bv_allocator_type >::optimize().
|
inline |
copy data from an external buffer
Definition at line 185 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::byte_buffer(), bm::byte_buffer< bv_allocator_type >::operator=(), and SerializationBufferTest().
|
inline |
Free mmemory.
Definition at line 276 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::allocate(), bm::dynamic_heap_matrix< unsigned, bv_allocator_type >::free(), bm::byte_buffer< bv_allocator_type >::move_from(), bm::byte_buffer< bv_allocator_type >::release(), and bm::byte_buffer< bv_allocator_type >::~byte_buffer().
|
inlinenoexcept |
return memory consumtion
Definition at line 266 of file bmbuffer.h.
|
inlinenoexcept |
take/move content from another buffer
Definition at line 164 of file bmbuffer.h.
Referenced by bm::dynamic_heap_matrix< unsigned, bv_allocator_type >::move_from(), bm::heap_matrix< Val, ROWS, COLS, BVAlloc >::move_from(), and bm::byte_buffer< bv_allocator_type >::operator=().
|
inlinenoexcept |
Move assignment operator.
Definition at line 128 of file bmbuffer.h.
|
inline |
Definition at line 135 of file bmbuffer.h.
|
inline |
try to shrink the capacity to more optimal size
Definition at line 253 of file bmbuffer.h.
Referenced by SerializationBufferTest().
|
inline |
reserve new capacity (buffer content NOT preserved, size set to 0)
Definition at line 247 of file bmbuffer.h.
|
inline |
reserve new capacity (buffer content NOT preserved, size set to 0)
Definition at line 239 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::reallocate(), and SerializationBufferTest().
|
inline |
Free underlying memory.
Definition at line 177 of file bmbuffer.h.
Referenced by TestCompressedCollection().
|
inline |
reserve new capacity (buffer content preserved)
Definition at line 223 of file bmbuffer.h.
Referenced by bm::sparse_vector< unsigned, bm::bvector<> >::back_insert_iterator::operator=(), bm::heap_vector< const bm::word_t *, allocator_type, true >::reserve(), bm::heap_vector< const bm::word_t *, allocator_type, true >::resize_internal(), and SerializationBufferTest().
|
inline |
adjust current size (buffer content preserved)
Definition at line 200 of file bmbuffer.h.
Referenced by bm::heap_matrix< Val, ROWS, COLS, BVAlloc >::heap_matrix(), bm::heap_vector< const bm::word_t *, allocator_type, true >::heap_vector(), bm::heap_matrix< Val, ROWS, COLS, BVAlloc >::init(), bm::dynamic_heap_matrix< unsigned, bv_allocator_type >::init(), bm::dynamic_heap_matrix< unsigned, bv_allocator_type >::init_resize(), bm::heap_vector< const bm::word_t *, allocator_type, true >::operator=(), bm::heap_vector< const bm::word_t *, allocator_type, true >::resize(), bm::heap_vector< const bm::word_t *, allocator_type, true >::resize_internal(), and bm::heap_vector< const bm::word_t *, allocator_type, true >::resize_no_copy().
|
inlinenoexcept |
adjust current size (no need to reallocate)
Definition at line 216 of file bmbuffer.h.
Referenced by bm::heap_vector< const bm::word_t *, allocator_type, true >::push_back_no_check(), bm::heap_vector< const bm::word_t *, allocator_type, true >::reset(), and bm::heap_vector< const bm::word_t *, allocator_type, true >::resize_no_check().
|
private |
Override from the base class.
|
inlinenoexcept |
swap content with another buffer
Definition at line 150 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::optimize(), bm::byte_buffer< bv_allocator_type >::reserve(), bm::byte_buffer< bv_allocator_type >::resize(), bm::dynamic_heap_matrix< unsigned, bv_allocator_type >::swap(), bm::heap_matrix< Val, ROWS, COLS, BVAlloc >::swap(), and bm::heap_vector< const bm::word_t *, allocator_type, true >::swap().
|
private |
number of blocks allocated for buffer
Definition at line 315 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::allocate(), bm::byte_buffer< bv_allocator_type >::byte_buffer(), bm::byte_buffer< bv_allocator_type >::free_buffer(), bm::byte_buffer< bv_allocator_type >::mem_usage(), bm::byte_buffer< bv_allocator_type >::move_from(), bm::byte_buffer< bv_allocator_type >::optimize(), and bm::byte_buffer< bv_allocator_type >::swap().
|
private |
current capacity
Definition at line 314 of file bmbuffer.h.
Referenced by bm::byte_buffer< bv_allocator_type >::allocate(), bm::byte_buffer< bv_allocator_type >::byte_buffer(), bm::byte_buffer< bv_allocator_type >::capacity(), bm::byte_buffer< bv_allocator_type >::mem_usage(), bm::byte_buffer< bv_allocator_type >::move_from(), bm::byte_buffer< bv_allocator_type >::release(), bm::byte_buffer< bv_allocator_type >::reserve(), bm::byte_buffer< bv_allocator_type >::resize(), bm::byte_buffer< bv_allocator_type >::resize_no_check(), and bm::byte_buffer< bv_allocator_type >::swap().