Loading...
Searching...
No Matches
Array< T > Class Template Reference

`#include <ftmpl_array.h>`

## Public Member Functions

| Array ()
| Array (const Array< T > &)
| Array (int size)
| Array (int min, int max)
| ~Array ()
Array< T > & | operator= (const Array< T > &)
T & | operator[] (int i) const
int | size () const
int | min () const
int | max () const
void | print (OSTREAM &) const

## Private Attributes

T * | data
int | _min
int | _max
int | _size

## Detailed Description

template<class T>
class Array< T >

Definition at line 18 of file ftmpl_array.h.

## Constructor & Destructor Documentation

## Array() [1/4]

template<class T>

Array< T >::Array | ( |  | ) |

Definition at line 6 of file ftmpl_array.cc.

: data(0), _min(0), _max(-1), _size(0)
{
}
Array::data
T * data
Definition ftmpl_array.h:20
Array::_min
int _min
Definition ftmpl_array.h:21
Array::_max
int _max
Definition ftmpl_array.h:22
Array::_size
int _size
Definition ftmpl_array.h:23

## Array() [2/4]

template<class T>

Array< T >::Array | ( | const Array< T > & | a | ) |

Definition at line 11 of file ftmpl_array.cc.

{
if ( a._size > 0 ) {
_min = a._min;
_max = a._max;
_size = a._size;
data = new T[_size];
for ( int i = 0; i < _size; i++ )
data[i] = a.data[i];
}
else {
data = 0;
_min = _size = 0;
_max = -1;
}
}
Array
Definition ftmpl_array.h:18

## Array() [3/4]

template<class T>

Array< T >::Array | ( | int | size | ) |

Definition at line 29 of file ftmpl_array.cc.

{
_min = 0;
_max = i-1;
_size = i;
if ( i == 0 )
data = 0;
else
data = new T[_size];
}

## Array() [4/4]

template<class T>

Array< T >::Array | ( | int | min,
|  | int | max )

Definition at line 41 of file ftmpl_array.cc.

{
if ( max < min ) {
_min = _size = 0;
_max = -1;
data = 0;
}
else {
_min = min;
_max = max;
_size = _max - _min + 1;
data = new T[_size];
}
}
Array::max
int max() const
Definition ftmpl_array.cc:104
Array::min
int min() const
Definition ftmpl_array.cc:98

## ~Array()

template<class T>

Array< T >::~Array | ( |  | ) |

Definition at line 57 of file ftmpl_array.cc.

{
delete [] data;
}

## Member Function Documentation

## max()

template<class T>

int Array< T >::max | ( |  | ) | const

Definition at line 104 of file ftmpl_array.cc.

{
return _max;
}

## min()

template<class T>

int Array< T >::min | ( |  | ) | const

Definition at line 98 of file ftmpl_array.cc.

{
return _min;
}

## operator=()

template<class T>

Array< T > & Array< T >::operator= | ( | const Array< T > & | a | ) |

Definition at line 63 of file ftmpl_array.cc.

{
if ( this != &a ) {
delete [] data;
_min = a._min;
_max = a._max;
_size = a._size;
if ( a._size > 0 ) {
_size = a._size;
data = new T[_size];
for ( int i = 0; i < _size; i++ )
data[i] = a.data[i];
}
else {
data = 0;
_size = 0;
}
}
return *this;
}

## operator[]()

template<class T>

T & Array< T >::operator[] | ( | int | i | ) | const

Definition at line 85 of file ftmpl_array.cc.

{
ASSERT( i >= _min && i <= _max, "warning: array size mismatch." );
return data[i-_min];
}
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99

## print()

template<class T>

void Array< T >::print | ( | OSTREAM & | os | ) | const

Definition at line 138 of file ftmpl_array.cc.

{
if ( _size == 0 )
os << "( )";
else {
os << "( " << data[0];
for ( int i = 1; i < _size; i++ )
os << ", " << data[i];
os << " )";
}
}

## size()

template<class T>

int Array< T >::size | ( |  | ) | const

Definition at line 92 of file ftmpl_array.cc.

{
return _size;
}

## Field Documentation

## _max

template<class T>

int Array< T >::_max

private

Definition at line 22 of file ftmpl_array.h.

## _min

template<class T>

int Array< T >::_min

private

Definition at line 21 of file ftmpl_array.h.

## _size

template<class T>

int Array< T >::_size

private

Definition at line 23 of file ftmpl_array.h.

## data

template<class T>

T* Array< T >::data

private

Definition at line 20 of file ftmpl_array.h.

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

- factory/include/factory/templates/ftmpl_array.h
- factory/templates/ftmpl_array.cc