libcommonc++  0.7
DynamicArray< T > Class Template Reference

A simple object wrapper for dynamically-allocated arrays. More...

#include <DynamicArray.h++>

Public Types

typedef T value_type
 
typedef T * iterator
 
typedef const T * const_iterator
 
typedef T & reference
 
typedef const T & const_reference
 

Public Member Functions

 DynamicArray (uint_t size)
 Construct a new DynamicArray with the given initial size. More...
 
 ~DynamicArray ()
 Destructor. More...
 
void resize (uint_t size, bool copy=false)
 Resize the array to a new size. More...
 
T * release ()
 Release ownership of the array. More...
 
bool isNull () const
 Determine if this array is NULL. More...
 
T * data ()
 Get the underlying array. More...
 
const T * data () const
 Get the underlying array. More...
 
uint_t size () const
 Get the size of the array. More...
 
T & operator[] (int index)
 Index operator. More...
 
operator[] (int index) const
 Index operator. More...
 
 operator T* ()
 Cast operator. More...
 
 operator const T * () const
 Cast operator. More...
 
bool operator! () const
 Unary NOT operator. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Detailed Description

template<typename T>
class ccxx::DynamicArray< T >

A simple object wrapper for dynamically-allocated arrays.

See section 17.5.4 of The C++ Programming Language. The array is heap-allocated and can be resized after construction. An array of length zero is considered to be "null".

Author
Mark Lindner

Member Typedef Documentation

◆ const_iterator

typedef const T* const_iterator

◆ const_reference

typedef const T& const_reference

◆ iterator

typedef T* iterator

◆ reference

typedef T& reference

◆ value_type

typedef T value_type

Constructor & Destructor Documentation

◆ DynamicArray()

DynamicArray ( uint_t  size)
inline

Construct a new DynamicArray with the given initial size.

Parameters
sizeThe initial size, as a number of elements.

◆ ~DynamicArray()

~DynamicArray ( )
inline

Destructor.

Member Function Documentation

◆ begin() [1/2]

iterator begin ( )
inline

◆ begin() [2/2]

const_iterator begin ( ) const
inline

◆ data() [1/2]

T* data ( )
inline

Get the underlying array.

Returns
A pointer to the beginning of the array.

◆ data() [2/2]

const T* data ( ) const
inline

Get the underlying array.

Returns
A pointer to the beginning of the array.

◆ end() [1/2]

iterator end ( )
inline

◆ end() [2/2]

const_iterator end ( ) const
inline

◆ isNull()

bool isNull ( ) const
inline

Determine if this array is NULL.

◆ operator const T *()

operator const T * ( ) const
inline

Cast operator.

◆ operator T*()

operator T* ( )
inline

Cast operator.

◆ operator!()

bool operator! ( ) const
inline

Unary NOT operator.

◆ operator[]() [1/2]

T& operator[] ( int  index)
inline

Index operator.

Exceptions
OutOfBoundsExceptionIf the index is invalid.

◆ operator[]() [2/2]

T operator[] ( int  index) const
inline

Index operator.

Exceptions
OutOfBoundsExceptionIf the index is invalid.

◆ release()

T* release ( )
inline

Release ownership of the array.

Returns
The array.

◆ resize()

void resize ( uint_t  size,
bool  copy = false 
)
inline

Resize the array to a new size.

Allocates a new array, and optionally copies as many elements from the old array as will fit to the new one.

Parameters
sizeThe new size, as a number of elements.
copyIf true, copy the elements from the old array.

◆ size()

uint_t size ( ) const
inline

Get the size of the array.

Returns
The size, in elements.

The documentation for this class was generated from the following file: