Scopira  20080306
scopira::tool::basic_array< T > Class Template Reference

#include <array.h>

Inheritance diagram for scopira::tool::basic_array< T >:
scopira::tool::basic_matrix< T >

Public Types

typedef T data_type
 
typedef T * iterator
 
typedef const T * const_iterator
 

Public Member Functions

 basic_array (void)
 
 basic_array (size_t len)
 
 basic_array (const basic_array &rhs)
 
 ~basic_array ()
 Destructor.
 
void resize (size_t newlen)
 
void array_swap (basic_array< T > &other)
 
T * array (void)
 
const T * array (void) const
 
T * c_array (void)
 
const T * c_array (void) const
 
iterator begin (void)
 
iterator end (void)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
basic_arrayoperator= (const basic_array &rhs)
 
void clear (void)
 
void clear_zero (void)
 
size_t size (void) const
 
bool empty (void) const
 
void set (size_t idx, const T &v)
 
const T & get (size_t idx) const
 
T & get (size_t idx)
 
const T & operator[] (size_t idx) const
 
T & operator[] (size_t idx)
 

Protected Attributes

T * dm_ary
 
size_t dm_len
 

Detailed Description

template<class T>
class scopira::tool::basic_array< T >

A generic, copyable array class. This should always be used instead of dynamic C-style arrays.

However, unlike std::vector, this one does NOT do incremental growth (or shrinkage)

Author
Aleksander Demko

Constructor & Destructor Documentation

◆ basic_array() [1/3]

template<class T>
scopira::tool::basic_array< T >::basic_array ( void  )
inline

Default constructor - makes a 0-length array.

Author
Aleksander Demko

◆ basic_array() [2/3]

template<class T>
scopira::tool::basic_array< T >::basic_array ( size_t  len)
inlineexplicit

Initialization constructor - makes a array of the given size. Each object will be initializaed via its default constructor (thus primitives will have undefined values).

Parameters
lenthe length of the new array

◆ basic_array() [3/3]

template<class T >
scopira::tool::basic_array< T >::basic_array ( const basic_array< T > &  rhs)

Deep-copy constructor.

Author
Aleksander Demko

Member Function Documentation

◆ array() [1/2]

template<class T>
T* scopira::tool::basic_array< T >::array ( void  )
inline

Raw access to the array

Author
Aleksander Demko

◆ array() [2/2]

template<class T>
const T* scopira::tool::basic_array< T >::array ( void  ) const
inline

Raw access to the array

Author
Aleksander Demko

◆ array_swap()

template<class T>
void scopira::tool::basic_array< T >::array_swap ( basic_array< T > &  other)
inline

Trade internal strucuters with the given array. This is useful for implementing non-destructive resize methods externally. An internal implementation goes against the principals. of this structure.

Parameters
otherThe array to swap with.
Author
Aleksander Demko

◆ begin() [1/2]

◆ begin() [2/2]

template<class T>
const_iterator scopira::tool::basic_array< T >::begin ( void  ) const
inline

STL-like iteration

Author
Aleksander Demko

◆ c_array() [1/2]

template<class T>
T* scopira::tool::basic_array< T >::c_array ( void  )
inline

Raw access to the array

Author
Aleksander Demko

◆ c_array() [2/2]

template<class T>
const T* scopira::tool::basic_array< T >::c_array ( void  ) const
inline

Raw access to the array

Author
Aleksander Demko

◆ clear()

template<class T>
void scopira::tool::basic_array< T >::clear ( void  )
inline

Does a resize(0)

Author
Aleksander Demko

◆ clear_zero()

template<class T>
void scopira::tool::basic_array< T >::clear_zero ( void  )
inline

Clears all the array values to binary 0. Does not resize the array. This is dangerous on non-POD classes.

Author
Aleksander Demko

◆ empty()

template<class T>
bool scopira::tool::basic_array< T >::empty ( void  ) const
inline

Is the array empty (0 length)?

Author
Aleksander Demko

◆ end() [1/2]

◆ end() [2/2]

template<class T>
const_iterator scopira::tool::basic_array< T >::end ( void  ) const
inline

STL-like iteration

Author
Aleksander Demko

◆ get() [1/2]

template<class T>
const T& scopira::tool::basic_array< T >::get ( size_t  idx) const
inline

Individual element setter

Author
Aleksander Demko

◆ get() [2/2]

template<class T>
T& scopira::tool::basic_array< T >::get ( size_t  idx)
inline

Individual element setter

Author
Aleksander Demko

◆ operator=()

template<class T >
scopira::tool::basic_array< T > & scopira::tool::basic_array< T >::operator= ( const basic_array< T > &  rhs)

Copy Operator. Does a deep copy.

Author
Aleksander Demko

◆ operator[]() [1/2]

template<class T>
const T& scopira::tool::basic_array< T >::operator[] ( size_t  idx) const
inline

Nice reference access

Author
Aleksander Demko

◆ operator[]() [2/2]

template<class T>
T& scopira::tool::basic_array< T >::operator[] ( size_t  idx)
inline

Nice reference access

Author
Aleksander Demko

◆ resize()

template<class T >
void scopira::tool::basic_array< T >::resize ( size_t  newlen)

Resizes the array. Please note the following: 1) If the new size is the current size, nothing will be done. 2) Resizes are destructive. All old values will be lost, and a new array is constructed (following the initialization rules specified in the constructor description)

Parameters
newlenthe new length
Author
Aleksander Demko

Referenced by scopira::tool::circular_vector< byte_t >::reserve().

◆ set()

template<class T>
void scopira::tool::basic_array< T >::set ( size_t  idx,
const T &  v 
)
inline

Individual element setter

Author
Aleksander Demko

◆ size()

template<class T>
size_t scopira::tool::basic_array< T >::size ( void  ) const
inline

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