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 >

List of all members.

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

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

Default constructor - makes a 0-length array.

Author:
Aleksander Demko
template<class T>
scopira::tool::basic_array< T >::basic_array ( size_t  len) [inline, explicit]

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
template<class T >
scopira::tool::basic_array< T >::basic_array ( const basic_array< T > &  rhs)

Member Function Documentation

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

Raw access to the array

Author:
Aleksander Demko
template<class T>
const T* scopira::tool::basic_array< T >::array ( void  ) const [inline]

Raw access to the array

Author:
Aleksander Demko
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
template<class T>
const_iterator scopira::tool::basic_array< T >::begin ( void  ) const [inline]

STL-like iteration

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

Raw access to the array

Author:
Aleksander Demko
template<class T>
const T* scopira::tool::basic_array< T >::c_array ( void  ) const [inline]

Raw access to the array

Author:
Aleksander Demko
template<class T>
void scopira::tool::basic_array< T >::clear ( void  ) [inline]

Does a resize(0)

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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
template<class T>
bool scopira::tool::basic_array< T >::empty ( void  ) const [inline]

Is the array empty (0 length)?

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

STL-like iteration

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

Individual element setter

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

Individual element setter

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

References scopira::tool::basic_array< T >::begin().

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

Nice reference access

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

Nice reference access

Author:
Aleksander Demko

Reimplemented in scopira::basekit::islice_vec_g< T >.

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

Reimplemented in scopira::tool::basic_matrix< T >, and scopira::basekit::islice_vec_g< T >.

Referenced by scopira::tool::basic_array< T >::basic_array(), scopira::tool::basic_array< byte_t >::basic_array(), scopira::tool::basic_array< byte_t >::clear(), and scopira::tool::basic_array< byte_t >::~basic_array().

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

Individual element setter

Author:
Aleksander Demko

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