sprint 1-alpha
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
sprint::shared_vector< _Tp, _Alloc > Class Template Reference

a shared vector More...

#include <shared_vector.h>

List of all members.

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
_Repalloc (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))

Detailed Description

template<typename _Tp, typename _Alloc = std::allocator<unsigned char>>
class sprint::shared_vector< _Tp, _Alloc >

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines