TVector< T > Class Template Reference
[Template Containers]

TVector provides a basic templated container for arrays of dynamic sizeTVector is a base class that is not meant to be derived from. More...

#include <tvector.h>

Public Member Functions

 TVector (int32 size=0, const T *items=0)
 Default constructor specifying the properties of the TVector.
 TVector (int32 size, const T &item)
 Constructor fills a given number of elements in the vector with copies of a given item.
 TVector (const TVector< T > &otherVector)
 Copy Constructor.
 ~TVector ()
TVector< T > & operator= (const TVector< T > &otherVector)
 < Destructor. Releases all memory allocated by the vector. The destructor is note declared virtual and thus derivation from TVector is not recommended.
TVector< T > & operator+= (const TVector< T > &otherVector)
 Append another vector to this vector.
TVector< T > operator+ (const TVector< T > &otherVector) const
 Create a new vector that appends the contents of another vector to this vector.
T & operator[] (int32 idx)
 Access operator.
T & at (int32 idx)
TVector< T > operator() (int32 idx, int32 size) const
 Function operator.
int32 size () const
const T * array () const
 < Returns the size of this vector
TVector< T > & assign (const T *items, int32 size=1)
 < Returns a const pointer to the first element stored in this vector. The pointer should not be stored as it will change on insertion and deletion of new elements.
TVector< T > & assign (const T &item, int32 size=1)
 Assign function that replaces this vector with an arbitrary number of copies of a given element.
TVector< T > & append (const T *items, int32 size=1)
 Append function that appends elements stored at the given pointer location to this vector.
TVector< T > & append (const T &item, int32 size=1)
 Append function that appends an arbitrary number of copies of a given element to this vector.
TVector< T > & insert (int32 idx, const TVector< T > &otherVector)
 Insert function that inserts another vector at a given position of this vector.
TVector< T > & insert (int32 idx, const T *items, int32 size=1)
 Insert function that inserts elements stored at the given pointer location at a given position into this vector.
TVector< T > & insert (int32 idx, const T &item, int32 size=1)
 Insert function that inserts an arbitrary number of copies of a given element into a given position in this vector.
TVector< T > & remove (int32 idx, int32 size=1)
 Removes items from the vector.
TVector< T > subVector (int32 idx, int32 size) const
 Used to extract a subset of the vector.
void clear ()
bool resize (int32 size)
 < Clears the vector and sets the size to 0
bool grow (int32 minSize, int32 delta=-1)

Detailed Description

template<class T>
class Steinberg::TVector< T >

TVector provides a basic templated container for arrays of dynamic size

TVector is a base class that is not meant to be derived from.

Elements can be stored and removed from the vector, always causing a resize to the appropriate new size.

Thus, the container always keeps a memory efficient perfect fit. TVector is not suited for high performance insert and removal operations. Consider to use a class with a more sophisticated allocation algorithm if the size of your container is bound to change often.

Insertions and removals on TVector are neither suited for real time processing and are not thread safe because reallocation of memory is neccesary. Random access to elements of the vector is lock free and thread safe.

Because of the TVectors policy to always reallocate new memory, it is not recommended to store pointers or references to the contents of the vector outside of TVector.


Constructor & Destructor Documentation

TVector ( int32  size = 0,
const T *  items = 0 
) [inline]

Default constructor specifying the properties of the TVector.

Parameters:
[in] size,: the number of items to be inserted on construction
[in] items,: pointer to the memory were the items are stored
TVector ( int32  size,
const T &  item 
) [inline]

Constructor fills a given number of elements in the vector with copies of a given item.

Parameters:
[in] size,: the number of copies of the given item to be inserted on construction
[in] item,: reference to the item that is to be copied
TVector ( const TVector< T > &  otherVector  )  [inline]

Copy Constructor.

Parameters:
[in] otherVector,: the vector that is to be copied on construction
~TVector (  )  [inline]

Member Function Documentation

TVector< T > & operator= ( const TVector< T > &  otherVector  )  [inline]

< Destructor. Releases all memory allocated by the vector. The destructor is note declared virtual and thus derivation from TVector is not recommended.

Assignment operator. TVector always reallocated new memory on assignment. Even when both vectors have the same size.

Parameters:
[in] otherVector,: the vector that is to be copied on assignment
TVector< T > & operator+= ( const TVector< T > &  otherVector  )  [inline]

Append another vector to this vector.

Parameters:
[in] otherVector,: The vector that should be appended to this vector
TVector< T > operator+ ( const TVector< T > &  otherVector  )  const [inline]

Create a new vector that appends the contents of another vector to this vector.

Parameters:
[in] otherVector,: The vector that should be appended to this vector
T & operator[] ( int32  idx  )  [inline]

Access operator.

Used for read and write access. Note that their is no const counterpart.

Parameters:
[in] idx,: The index of the element to be accessed. If idx < 0, idx is set to 0. If idx >= (size of this vector), the vector is resized to idx to make access possible.
T& at ( int32  idx  )  [inline]
TVector< T > operator() ( int32  idx,
int32  size 
) const [inline]

Function operator.

Used to extract a subset of the vector. The returned vector is a new vector that contains copies of the elements in the requested subset.

Parameters:
[in] idx,: The index of the first element of the subvector. If idx < 0 or idx >= (size of this vector), an empty vector is returned.
[in] size,: Number of elements to be contained in the new vector. If idx + size > (size of this vector), an empty vector is returned.
int32 size (  )  const [inline]
const T* array (  )  const [inline]

< Returns the size of this vector

TVector< T > & assign ( const T *  items,
int32  size = 1 
) [inline]

< Returns a const pointer to the first element stored in this vector. The pointer should not be stored as it will change on insertion and deletion of new elements.

Assign function that replaces this vector with the elements stored at the given pointer location. Always allocates new memory.

Parameters:
[in] items,: pointer to the memory were the items are stored.
[in] size,: the number of items to be inserted.
TVector< T > & assign ( const T &  item,
int32  size = 1 
) [inline]

Assign function that replaces this vector with an arbitrary number of copies of a given element.

Always allocates new memory.

Parameters:
[in] item,: reference to the item that is to be copied.
[in] size,: the number of copies of the given item to be inserted.
TVector< T > & append ( const T *  items,
int32  size = 1 
) [inline]

Append function that appends elements stored at the given pointer location to this vector.

Always allocates new memory.

Parameters:
[in] items,: pointer to the memory were the items are stored.
[in] size,: the number of items to be appended.
TVector< T > & append ( const T &  item,
int32  size = 1 
) [inline]

Append function that appends an arbitrary number of copies of a given element to this vector.

Always allocates new memory.

Parameters:
[in] item,: reference to the item that is to be copied.
[in] size,: the number of copies of the given item to bo appended.
TVector< T > & insert ( int32  idx,
const TVector< T > &  otherVector 
) [inline]

Insert function that inserts another vector at a given position of this vector.

Always allocates new memory.

Parameters:
[in] idx,: index at wich to insert the new vector. If idx = 0, the other vector will be prepended to this vector.
[in] otherVector,: const reference to the other vector that is to be inserted into this vector.
TVector< T > & insert ( int32  idx,
const T *  items,
int32  size = 1 
) [inline]

Insert function that inserts elements stored at the given pointer location at a given position into this vector.

Always allocates new memory.

Parameters:
[in] idx,: index at wich to insert the new items. If idx = 0, the other items will be prepended to this vector. If idx < 0 or index > (size of this vector), nothing will be inserted.
[in] items,: pointer to the memory were the items are stored.
[in] size,: the number of items to be inserted .
TVector< T > & insert ( int32  idx,
const T &  item,
int32  size = 1 
) [inline]

Insert function that inserts an arbitrary number of copies of a given element into a given position in this vector.

Always allocates new memory.

Parameters:
[in] idx,: index at wich to insert the new items. If idx = 0, the other items will be prepended to this vector. If idx < 0 or index > (size of this vector), nothing will be inserted.
[in] item,: reference to the item that is to be copied.
[in] size,: the number of copies of the given item to be inserted.
TVector< T > & remove ( int32  idx,
int32  size = 1 
) [inline]

Removes items from the vector.

Always allocates new memory.

Parameters:
[in] idx,: The index of the first element to be removed from the vector. If idx < 0 idx >= (size of this vector), the vector is returned unchanged.
[in] size,: Number of elements to be removed from the vector. If idx + size >= (size of this vector), the vector is returned unchanged.
TVector< T > subVector ( int32  idx,
int32  size 
) const [inline]

Used to extract a subset of the vector.

The returned vector is a new vector that contains copies of the elements in the requested subset.

Parameters:
[in] idx,: The index of the first element of the subvector. If idx < 0 or idx > (size of this vector), an empty vector is returned.
[in] size,: Number of elements to be contained in the new vector. If idx + size > (size of this vector), an empty vector is returned.
void clear (  )  [inline]
bool resize ( int32  size  )  [inline]

< Clears the vector and sets the size to 0

Resize the whole vector and copies the contained elements to a new location. Always allocates new memory. Even if size == (size of this vector)

Parameters:
[in] size,: size of the vector after resize.
bool grow ( int32  minSize,
int32  delta = -1 
) [inline]
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.