In file CWVec/CWVec.hh:

template <class T> class CWVec

Copy on write data vector class template.

Inheritance:


Public Methods

explicit CWVec (size_type L=0, const T* data=0, bool cpy=true)
Basic constructor.
explicit CWVec (const CWVec& x)
Limited copy constructor.
~CWVec (void)
Destructor.
void access (void)
Request a writeable copy of the data vector.
size_type capacity (void) const
Internal vector capacity
void clear (void)
Zero the data length.
void replace (vec_node* v)
Replace the vector node.
void release (void)
Release a read instance.
size_type size (void) const
Get the CW vector size.
const T* ref (void) const
Get a constant reference to the data vector.
T* ref (void)
Get a writable reference to the data vector.
void reserve (size_type N)
Insure that a vector of the specified size is available.
void resize (size_type N)
Shrink or extend the vector with uninitialized data.
bool shared (void) const
Test whether vector is shared.
void substr (size_type inx=0, size_type len=0)
take a substring of the current vector.
CWVec& operator= (const CWVec& v)
Get a constant reference to a data word.
const T& operator[] (size_type i) const
Get a constant reference to a data word.
T& operator[] (size_type i)
Get a writable reference to a data word.

Documentation

The CWVec classes allow data to be shared by more than one Data vector without forcing a copy. This is especially useful for reducing overheads when passing ownership of long data vectors. A data vector can be copied using the Clone() method, and when write access is needed, Access() is used.
explicit CWVec(size_type L=0, const T* data=0, bool cpy=true)
Construct a data vector of Length L. If the data pointer is non-null, the indicated data are copied into the vector. Otherwise the vector is left uninitialized.
Parameters:
L - Length of the vector to be created in data words.
data - Optional initial data values.

explicit CWVec(const CWVec& x)
Constructor a new CWVec identical to the first argument, but copy only the specified number of data words.

~CWVec(void)
Delete the vector.

void access(void)
Get a pointer to a writeable copy of the vector. This function results in copying the vector if there is more than one user of this data.
Returns:
Pointer to a writeable CWVec with the same contents.

size_type capacity(void) const
Get the capacity of the internal vector.
Returns:
Vector capacity.

void clear(void)
Clear the vector by zeroing the data length. Note that the data vector is not released.

void replace(vec_node* v)
The current vec_node is released and deleted if its use count falls to zero. The vec_node is address is then set to the specified address. Note that the argument vec_node must have its instance count set appropriately before it is passed to replace().
Parameters:
v - pointer to the new vector node.

void release(void)
Release a read instance. Delete the vector if it is unused.

size_type size(void) const
Get the number of words allocated by the CW vector.

const T* ref(void) const
Get a constant reference to the data vector.

T* ref(void)
Get a writable reference to the data vector.

void reserve(size_type N)
Insure that the specified number of data words are available in the data vector. If the requested data length is less than the current data length, no action is taken. If the requested data length is greater than the current length, a new vector is allocated and the existing data are copied.

void resize(size_type N)
Extend the vector to the specified length. Existing data are copied if necessary, but added words are not initialized. If the requested data length is less than the current length, no action is taken other than updating the current length. If the requested length is zero, the index is also set to zero. Resize does not request write access.

bool shared(void) const
Return true if internal data vector is shared with another CWVec.

void substr(size_type inx=0, size_type len=0)
Modify CWVec limits to contain a substring of the current vector. If len is zero or inx+len is greater than the current string length, the substring extends to the end of the current string.

CWVec& operator=(const CWVec& v)
Get a constant reference to a data word.

const T& operator[](size_type i) const
Get a constant reference to a data word.

T& operator[](size_type i)
Get a writable reference to a data word.


This class has no child classes.

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++