|
sprint 1-alpha
|
a shared vector More...
#include <shared_vector.h>
Classes | |
| struct | _Rep |
Public Member Functions | |
| shared_vector (long size=suggestedSize) | |
| shared_vector (const shared_vector &s) | |
| void | resize (long new_size) |
| expand effective memory used, and there is not enough capacity using alloc and release change memory size | |
| void | reserve (long reserve) |
| reserve capacity for, at least, reserve elements | |
| int | size () const |
| return the size of vector | |
| int | capacity () const |
| return the capacity of vector | |
| _Tp & | operator[] (int i) |
| _Tp * | begin () |
| first element | |
| const _Tp * | begin () const |
| const _Tp * | end () const |
| last element | |
| const _Tp & | operator[] (int i) const |
| bool | unique () const |
| long | use_count () const |
Protected Member Functions | |
| _Rep * | _M_rep () const |
| _Rep * | alloc (long size) |
| void | release (_Rep *r) |
Protected Attributes | |
| _Tp * | m_data |
| the string starting point (not the memory starting point) | |
Static Protected Attributes | |
| static const int | suggestedSize = (65536 - sizeof(_Rep)/sizeof(_Tp)) |
a shared vector
a shared vector is like std::vector but with an internal reference count in order to avoid copy when passed as parameter or stored. Reduce memory fragmentation and the sizeof(shared_vector) = sizeof(void *) + sizeof(_Alloc): usually 4/8 bytes.
1.7.4