SimpleArray Class Template Reference

An array data type that manages the allocation and deallocation of memory. More...

#include <SimpleArray.h>

Inheritance diagram for SimpleArray::

BasicArray NumArray List of all members.

Public Methods

 SimpleArray ()
 Null constructor.

 SimpleArray (const int len, T *d=((T *) 0), const EnumDataOwned o=DataNotOwned)
 Constructor that initializes the length and possibly data. More...

 SimpleArray (const SimpleArray< T > &array)
 Copy constructor.

SimpleArray< T > & operator= (const SimpleArray< T > &array)
 Copies the array object by constructing a new SimpleArray.

SimpleArray< T > & operator= (const T &val)
 Set all elements of the array to val.

virtual ~SimpleArray ()
 Destructor.

int operator== (const T &val) const
 Checks to see if the entire array equals val.

int operator!= (const T &val) const
 Checks to see if the entire array does not equal val.

int operator== (const SimpleArray< T > &array) const
 Checks to see if the current array equals array.

int operator!= (const SimpleArray< T > &array) const
 Checks to see if the current array does not equal array.

int compare (const SimpleArray< T > &array) const
 Compares the current array with array. More...

virtual int write (ostream &os) const
 Write the array to an output stream. More...

virtual int read (istream &is)
 Read the array from an input stream.

virtual int write (PackBuffer &os) const
 Pack the array into a PackBuffer class.

virtual int read (UnPackBuffer &is)
 Unpack the array from an UnPackBuffer class.


Detailed Description

template<class T>
class SimpleArray< T >

An array data type that manages the allocation and deallocation of memory.

The SimpleArray class extends the BasicArray class to include I/O operations and comparison methods.


Constructor & Destructor Documentation

template<class T>
SimpleArray< T >::SimpleArray const int    len,
T *    d = ((T*)0),
const EnumDataOwned    o = DataNotOwned
[inline, explicit]
 

Constructor that initializes the length and possibly data.

The len parameter specifies the length of the array. If the d parameter is not null, then this array is assumed to have length len. The initialization of the array then depends upon the value of the o parameter. If o is DataNotOwned (the default), then the data is copied from d. Otherwise, the internal point is set to d and the internal ownership flag is set to o.


Member Function Documentation

template<class T>
int SimpleArray< T >::compare const SimpleArray< T > &    array const
 

Compares the current array with array.

If the current array is longer, then returns 1. If shorter, then returns -1. Otherwise, does a pairwise comparison on elements of both arrays. If there exists a nonequal pair of elements, then returns 1 if the current array is greater and -1 otherwise.

template<class T>
int SimpleArray< T >::write ostream &    os const [inline, virtual]
 

Write the array to an output stream.

The format for this output is

 <len> : <elt-1> ... <elt-n> 

Reimplemented in CharString.


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