Main Page | Class Hierarchy | Class List | File List | Class Members

Array< T > Class Template Reference

#include <prom_options.hh>

Collaboration diagram for Array< T >:

Collaboration graph
[legend]
List of all members.

[NOHEADER]

int hashCode () const
String toString () const
int byteCount () const
int indexCheckCrash (int i) const
bool indexCheckNoCrash (int i) const
T * data_
int len_
int reserve_

Public Member Functions

 Array (const Array< T > &other)
const Array< T > & operator= (const Array< T > &other)
 Array ()
 Array (int n)
 Array (int n, const T *cArray)
 Array (int n, const T &t)
int length () const
void resize (int newN)
void reserve (int n)
int reserve () const
Array< T > & append (const T &rhs)
T & operator[] (int i)
const T & operator[] (int i) const
void remove (int i)

Detailed Description

template<class T>
class Array< T >

class Array Templated, safe, resizable array class.

Classes to be stored in an Array must provide an empty constructor, plus valid copy ctor, assignment operator, and dtor (these last three need not be provided explicitly when the default will suffice).

Copying and assignment of an Array does a deep copy. If you want shallow copy behavior, create an Array of SmartPtrs or handles.

Bounds are checked upon access, unless the NOBOUNDSCHECK flag has been set at compile time. Bounds checking can slow down critical code by at least an order of magnitude, so we recommend turning bounds checking off for distribution code. A bad memory read or write can cause a serious error, so we recommend leaving bounds checking on during development.

Author:
Kevin Long and Leslea Lehoucq


Constructor & Destructor Documentation

template<class T>
Array< T >::Array  )  [inline]
 

Empty ctor

template<class T>
Array< T >::Array int  n  )  [inline]
 

Allocate an array with n elements

template<class T>
Array< T >::Array int  n,
const T *  cArray
[inline]
 

Copy n elements from a C array

template<class T>
Array< T >::Array int  n,
const T &  t
[inline]
 

Allocate n elements, and fill with value


Member Function Documentation

template<class T>
Array< T > & Array< T >::append const T &  rhs  )  [inline]
 

Stick a new entry at the end of the array. Resize to allow space for the new entry

template<class T>
int Array< T >::byteCount  )  const [inline]
 

compute number of bytes needed to store array

template<class T>
int Array< T >::hashCode  )  const [inline]
 

compute a hash code for the array

template<class T>
int Array< T >::length  )  const [inline]
 

get number of elements.

template<class T>
const T & Array< T >::operator[] int  i  )  const [inline]
 

Read-only access to a the i-th element. If NOBOUNDSCHECK is not set, throw a IndexRangeException upon violation of bounds.

template<class T>
T & Array< T >::operator[] int  i  )  [inline]
 

Read/Write access to a the i-th element. If NOBOUNDSCHECK is not set, throw a IndexRangeException upon violation of bounds.

template<class T>
void Array< T >::remove int  i  )  [inline]
 

Remove the i-th element. Subsequent elements are bumped back to fill in the hole.

template<class T>
int Array< T >::reserve  )  const [inline]
 

get preallocated space

template<class T>
void Array< T >::reserve int  n  )  [inline]
 

preallocate space

template<class T>
void Array< T >::resize int  newN  )  [inline]
 

change size

template<class T>
String Array< T >::toString  )  const [inline]
 

return String form


The documentation for this class was generated from the following file:
Generated on Fri May 21 14:17:55 2004 by doxygen 1.3.7