NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

arr< T > Class Template Reference
[Array classes]

#include <arr.h>

Inheritance diagram for arr< T >:

List of all members.

Public Member Functions

 arr ()
 arr (long sz)
 arr (long sz, const T &inival)
 arr (T *ptr, long sz)
 arr (const arr &orig)
 ~arr ()
long size () const
void alloc (long sz)
void dealloc ()
void fill (const T &val)
arroperator= (const arr &orig)
template<typename T2>
T & operator[] (T2 n)
template<typename T2>
const T & operator[] (T2 n) const
void sort ()
void minmax (T &minv, T &maxv) const
void transfer (arr &other)
void swap (arr &other)


Detailed Description

template<typename T>
class arr< T >

One-dimensional array type.

Definition at line 62 of file arr.h.


Constructor & Destructor Documentation

template<typename T>
arr< T >::arr (  )  [inline]

Creates a zero-sized array.

Definition at line 83 of file arr.h.

template<typename T>
arr< T >::arr ( long  sz  )  [inline]

Creates an array with sz entries.

Definition at line 85 of file arr.h.

template<typename T>
arr< T >::arr ( long  sz,
const T &  inival 
) [inline]

Creates an array with sz entries, and initializes them with inival.

Definition at line 88 of file arr.h.

template<typename T>
arr< T >::arr ( T *  ptr,
long  sz 
) [inline]

Creates an array with sz entries, which uses the memory pointed to by ptr.

Note:
ptr will not be deallocated by the destructor.
Warning:
Only use this if you REALLY know what you are doing. In particular, this is only safely usable if
  • T is a POD type
  • ptr survives during the lifetime of the array object
  • ptr is not subject to garbage collection
Other restrictions may apply. You have been warned.

Definition at line 101 of file arr.h.

template<typename T>
arr< T >::arr ( const arr< T > &  orig  )  [inline]

Creates an array which is a copy of orig. The data in orig is duplicated.

Definition at line 104 of file arr.h.

template<typename T>
arr< T >::~arr (  )  [inline]

Frees the memory allocated by the object.

Definition at line 107 of file arr.h.


Member Function Documentation

template<typename T>
long arr< T >::size (  )  const [inline]

Returns the current array size.

Definition at line 110 of file arr.h.

template<typename T>
void arr< T >::alloc ( long  sz  )  [inline]

Allocates space for sz elements. The content of the array is undefined on exit. sz can be 0. If sz is the same as the current size, no reallocation is performed.

Definition at line 115 of file arr.h.

template<typename T>
void arr< T >::dealloc (  )  [inline]

Deallocates the memory held by the array, and sets the array size to 0.

Definition at line 125 of file arr.h.

template<typename T>
void arr< T >::fill ( const T &  val  )  [inline]

Writes val into every element of the array.

Definition at line 128 of file arr.h.

template<typename T>
arr& arr< T >::operator= ( const arr< T > &  orig  )  [inline]

Changes the array to be a copy of orig.

Definition at line 132 of file arr.h.

template<typename T>
template<typename T2>
T& arr< T >::operator[] ( T2  n  )  [inline]

Returns a reference to element n

Definition at line 146 of file arr.h.

template<typename T>
template<typename T2>
const T& arr< T >::operator[] ( T2  n  )  const [inline]

Returns a constant reference to element n

Definition at line 148 of file arr.h.

template<typename T>
void arr< T >::sort (  )  [inline]

Sorts the elements in the array, in ascending order.

Definition at line 155 of file arr.h.

template<typename T>
void arr< T >::minmax ( T &  minv,
T &  maxv 
) const [inline]

Returns the minimum and maximum entry in minv and maxv, respectively. Throws an exception if the array is zero-sized.

Definition at line 160 of file arr.h.

template<typename T>
void arr< T >::transfer ( arr< T > &  other  )  [inline]

Assigns the contents and size of other to the array. On exit, other is yero-sized.

Definition at line 173 of file arr.h.

template<typename T>
void arr< T >::swap ( arr< T > &  other  )  [inline]

Swaps contents and size with other.

Definition at line 176 of file arr.h.


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

Generated on Fri Jun 18 16:12:29 2010 for LevelS C++ support library
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650