Class cv::AutoBuffer#
Automatically Allocated Buffer Class. View details
#include <opencv2/core/utility.hpp>Collaboration diagram for cv::AutoBuffer:
Detailed Description#
Automatically Allocated Buffer Class.
The class is used for temporary buffers in functions and methods. If a temporary buffer is usually small (a few K’s of memory), but its size depends on the parameters, it makes sense to create a small fixed-size array on stack and use it if it’s large enough. If the required buffer size is larger than the fixed size, another buffer of sufficient size is allocated dynamically and released after the processing. Therefore, in typical cases, when the buffer size is small, there is no overhead associated with malloc()/free(). At the same time, there is no limit on the size of processed data.
This is what AutoBuffer does. The template takes 2 parameters - type of the buffer elements and the number of stack-allocated elements. Here is how the class is used:
void my_func(const cv::Mat& m)
{
cv::AutoBuffer<float> buf(1000); // create automatic buffer containing 1000 floats
buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used,
// otherwise the buffer of "m.rows" floats will be allocated
// dynamically and deallocated in cv::AutoBuffer destructor
...
}
Member Typedef Documentation#
const_iterator#
typedef const _Tp * cv::AutoBuffer::const_iterator
const_reference#
typedef const _Tp & cv::AutoBuffer::const_reference
difference_type#
typedef std::ptrdiff_t cv::AutoBuffer::difference_type
iterator#
typedef _Tp * cv::AutoBuffer::iterator
reference#
typedef _Tp & cv::AutoBuffer::reference
size_type#
typedef std::size_t cv::AutoBuffer::size_type
value_type#
typedef _Tp cv::AutoBuffer::value_type
Constructor & Destructor Documentation#
AutoBuffer()#
the default constructor
AutoBuffer()#
cv::AutoBuffer::AutoBuffer(const AutoBuffer< _Tp, fixed_size > & buf)
the copy constructor
AutoBuffer()#
cv::AutoBuffer::AutoBuffer(size_t _size)
constructor taking the real buffer size
AutoBuffer()#
cv::AutoBuffer::AutoBuffer(
size_t _size,
const _Tp & value )
~AutoBuffer()#
destructor. calls deallocate()
Member Function Documentation#
allocate()#
void cv::AutoBuffer::allocate(size_t _size)
allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used
back()#
reference cv::AutoBuffer::back()
back()#
const_reference cv::AutoBuffer::back()
begin()#
iterator cv::AutoBuffer::begin()
begin()#
const_iterator cv::AutoBuffer::begin()
cbegin()#
const_iterator cv::AutoBuffer::cbegin()
cend()#
const_iterator cv::AutoBuffer::cend()
clear()#
void cv::AutoBuffer::clear()
Here is the call graph for this function:
data()#
_Tp * cv::AutoBuffer::data()
returns pointer to the real buffer, stack-allocated or heap-allocated
data()#
const _Tp * cv::AutoBuffer::data()
returns read-only pointer to the real buffer, stack-allocated or heap-allocated
deallocate()#
void cv::AutoBuffer::deallocate()
deallocates the buffer if it was dynamically allocated
emplace_back()#
void cv::AutoBuffer::emplace_back(_Tp && value)
empty()#
bool cv::AutoBuffer::empty()
end()#
iterator cv::AutoBuffer::end()
end()#
const_iterator cv::AutoBuffer::end()
front()#
reference cv::AutoBuffer::front()
front()#
const_reference cv::AutoBuffer::front()
operator _Tp *()#
cv::AutoBuffer::operator _Tp *()
returns pointer to the real buffer, stack-allocated or heap-allocated
operator const _Tp *()#
cv::AutoBuffer::operator const _Tp *()
returns read-only pointer to the real buffer, stack-allocated or heap-allocated
operator=()#
AutoBuffer< _Tp, fixed_size > & cv::AutoBuffer::operator=(const AutoBuffer< _Tp, fixed_size > & buf)
the assignment operator
pop_back()#
void cv::AutoBuffer::pop_back()
Here is the call graph for this function:
push_back()#
void cv::AutoBuffer::push_back(_Tp && value)
Here is the call graph for this function:
push_back()#
void cv::AutoBuffer::push_back(const _Tp & value)
Here is the call graph for this function:
resize()#
void cv::AutoBuffer::resize(size_t _size)
resizes the buffer and preserves the content
size()#
size_t cv::AutoBuffer::size()
returns the current buffer size
Member Data Documentation#
buf#
_Tp cv::AutoBuffer::buf
pre-allocated buffer. At least 1 element to confirm C++ standard requirements
ptr#
_Tp * cv::AutoBuffer::ptr
pointer to the real buffer, can point to buf if the buffer is small enough
sz#
size_t cv::AutoBuffer::sz
size of the real buffer
Source file#
The documentation for this class was generated from the following file:
opencv2/core/utility.hpp