Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OSCAR::Array< Type > Class Template Reference

#include <Array.h>

Inheritance diagram for OSCAR::Array< Type >:

Inheritance graph
[legend]
List of all members.

Public Methods

 Array (unsigned int sz, const Type *array=0)
 Array (const Array< Type > &rhs)
virtual ~Array (void)
Array< Type > & operator= (const Array< Type > &rhs)
bool Copy (const Array< Type > &arrayToCopy)
unsigned int GetSize () const
bool Grow (unsigned int growth)
bool Output (std::ostream &out) const
bool Input (std::istream &in)
Type & at (unsigned int index)
const Type & at (unsigned int index) const
Type & operator[] (unsigned int index)
const Type & operator[] (unsigned int index) const
const Type * GetArray () const
Type * GetArray ()

Protected Methods

void init (unsigned int size, const Type *array=0)
 Array ()

Protected Attributes

unsigned int size
Type * element

template<class Type>
class OSCAR::Array< Type >


Constructor & Destructor Documentation

template<class Type>
OSCAR::Array< Type >::Array unsigned int    sz,
const Type *    array = 0
[explicit]
 

Constructor.

Constructs an Array of size sz and to initialize all its elements by values in array Explicit keyword prevents implicit conversion from a scalar to an Array object

Parameters:
sz the size(length) of the Array to be create
array A pointer to an array of Type of size sz. Values from this will be used to initialize the Array elements. The default for this is 0, which implies that the elements of Array will not be initialized

template<class Type>
OSCAR::Array< Type >::Array const Array< Type > &    rhs
 

Copy Constructor.

This is the Copy constructor for an object of type Array. Use this to construct an Array object from an existing Array object.

Parameters:
rhs An Array object that will be used to initialize this new object.

template<class Type>
virtual OSCAR::Array< Type >::~Array void    [virtual]
 

Virtual Destructor for Array.

This is the Destructor for an Array object.

template<class Type>
OSCAR::Array< Type >::Array   [protected]
 

Constructor.

Default Constructor. This does nothing. Its only used for stack allocation in derived classes. Sets internal memory pointer to 0. This prevents the destructor from deallocating


Member Function Documentation

template<class Type>
const Type& OSCAR::Array< Type >::at unsigned int    index const
 

Get an individual element in an Array object.

This method is used read an individual element in a const RRAarray object. No range checking is performed in this method. Ths method can be used on both sides of the = operator

Parameters:
index The index of the element to be accessed.
Returns:
A reference to the element located at that index.

template<class Type>
Type& OSCAR::Array< Type >::at unsigned int    index
 

Get an individual element in an Array object.

This method is used to read/write individual element in a non-const RRAarray object. No range checking is performed in this method. Ths method can be used on both sides of the = operator

Parameters:
index The index of the element to be accessed.
Returns:
A reference to the element located at that index.

template<class Type>
bool OSCAR::Array< Type >::Copy const Array< Type > &    arrayToCopy
 

Copy an Array.

This method is used to copy an Array. It will return false if the arrays are of different sizes or if an error is thrown while copying the individual elements. It will not resize like the operator equals.

Parameters:
arrayToCopy The Array to be copied. This should be the same size as that of the calling object
Returns:
true if successful, false if unsuccessful
See also:
operator=()

template<class Type>
Type* OSCAR::Array< Type >::GetArray  
 

Get a pointer to the Array of elements.

Returns a pointer to the first element in the array elements.

Returns:
A pointer to the Array of elements.

template<class Type>
const Type* OSCAR::Array< Type >::GetArray   const
 

Get a pointer to the Array of const elements.

This constant function is used to get a pointer to the Array of elements.

Returns:
A pointer to the Array of elements.

template<class Type>
unsigned int OSCAR::Array< Type >::GetSize   const
 

Get the size.

This method is used to get the size(number of elements) in an Array object.

Returns:
The size of the Array

template<class Type>
bool OSCAR::Array< Type >::Grow unsigned int    growth
 

Allocate more space.

This method is used to increase the size(number of elements) in an Array object.

Parameters:
growth The number of elements by which the Array should grow.
Returns:
true if successful and false if not.

template<class Type>
void OSCAR::Array< Type >::init unsigned int    size,
const Type *    array = 0
[protected]
 

Allocate memory and initialize the Array object.

This method is used to allocate memory for an Array object and initialize it with an existing Array. This method is called by the constructors.

Parameters:
size The size of the Array object.
array A pointer to the existing Array object. If the calling function does not specify a value for array(second parameter), then the value for array defaults to 0. (Once inside the body of the method init, no value can be assigned to array.)

template<class Type>
bool OSCAR::Array< Type >::Input std::istream &    in
 

Input the Array object from an input stream.

This method is used to input an Array object from an input stream.

Parameters:
in The input stream from which the Array object is to be inputted.
Returns:
true if successful and false if not. Call GetError() to get detailed error information

template<class Type>
Array<Type>& OSCAR::Array< Type >::operator= const Array< Type > &    rhs
 

Assignment operator.

This is the Assignment operator for an object of type Array. This operator will resize the calling object if the array being copied is not of the same size.

Parameters:
rhs An Array<Type> object that goes on the right hand side of the = operator.
Returns:
A reference to the object on the left hand side of the = operator.
See also:
Copy(const Array<Type>& arrayToCopy)

template<class Type>
const Type& OSCAR::Array< Type >::operator[] unsigned int    index const
 

Overloaded operator[].

This overloaded operator[] is used to read individual elements in const Array objects. Range checking is performed in this method and it will abort if index is out of range. Ths method can be used on both sides of the = operator. This method will abort if index is out of range.

Parameters:
index The index of the element to be accessed.
Returns:
A reference to the element located at that index.
Exceptions:
outOfRange outOfRange

template<class Type>
Type& OSCAR::Array< Type >::operator[] unsigned int    index
 

Overloaded operator[].

This overloaded operator[] is used to read/write individual elements in non-const Array objects. Range checking is performed in this method and it will abort if index is out of range. Ths method can be used on both sides of the = operator. This method will abort if index is out of range.

Parameters:
index The index of the element to be accessed.
Returns:
A reference to the element located at that index.
Exceptions:
outOfRange outOfRange

template<class Type>
bool OSCAR::Array< Type >::Output std::ostream &    out const
 

Output the Array object to an output stream.

This method is used to output an Array object to an output stream.

Parameters:
out The output stream to which the Array object is to be outputted.
Returns:
true if successful and false if not. Call GetError() to get detailed error information


Member Data Documentation

template<class Type>
Type* OSCAR::Array< Type >::element [protected]
 

template<class Type>
unsigned int OSCAR::Array< Type >::size [protected]
 


The documentation for this class was generated from the following file:
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations