ABA_ARRAY< Type > Class Template Reference

it is a template for arrays. It can be used like a ``normal'' C-style array More...

#include <array.h>

Inheritance diagram for ABA_ARRAY< Type >:

ABA_ABACUSROOT List of all members.

Public Member Functions

 ABA_ARRAY (ABA_GLOBAL *glob, int size)
 ABA_ARRAY (ABA_GLOBAL *glob, int size, Type init)
 ABA_ARRAY (ABA_GLOBAL *glob, const ABA_BUFFER< Type > &buf)
 ABA_ARRAY (const ABA_ARRAY< Type > &rhs)
 ~ABA_ARRAY ()
 The destructor.
const ABA_ARRAY< Type > & operator= (const ABA_ARRAY< Type > &rhs)
const ABA_ARRAY< Type > & operator= (const ABA_BUFFER< Type > &rhs)
 To assign an object of the class ABA_BUFFER to an object of the class ABA_ARRAY the size of the left hand side must be at least the size of rhs. Then all buffered elements of rhs are copied.
Type & operator[] (int i)
const Type & operator[] (int i) const
void copy (const ABA_ARRAY< Type > &rhs)
void copy (const ABA_ARRAY< Type > &rhs, int l, int r)
 This version of the function copy() copies the elements rhs[l], rhs[l+1],, rhs[r] into the components 0,,r-l of the array.
void leftShift (ABA_BUFFER< int > &ind)
 Removes the components listed in ind by shifting the remaining components to the left.
void leftShift (ABA_ARRAY< bool > &remove)
 This version of the function leftShift() removes all components i with marked[i]==true from the array by shifting the other components to the left.
void set (int l, int r, Type val)
void set (Type val)
 This version of the function set() initializes all components of the array with the same value.
int size () const
void realloc (int newSize)
 The length of an array can be changed with the function realloc(). If the array is enlarged all elements of the old array are copied and the values of the additional new elements are undefined. If the array is shortened only the first newSize elements are copied.
void realloc (int newSize, Type init)
 Is overloaded such that also an initialization with a new value of the elements of the array after reallocation is possible.

Private Member Functions

void rangeCheck (int i) const
 Stops the program with an error message if the index i is not within the bounds of the array.

Private Attributes

ABA_GLOBALglob_
int n_
Type * a_

Friends

ostream & operator<< (ostream &out, const ABA_ARRAY< Type > &array)
 The output operator writes first the number of the element and a ':' followed by the value of the element line by line to the stream out.

Detailed Description

template<class Type>
class ABA_ARRAY< Type >

it is a template for arrays. It can be used like a ``normal'' C-style array

Definition at line 53 of file array.h.


Constructor & Destructor Documentation

template<class Type>
ABA_ARRAY< Type >::ABA_ARRAY ( ABA_GLOBAL glob,
int  size 
)

A constructor without initialization.

Parameters:
glob A pointer to the corresponding global object.
size The length of the array.

template<class Type>
ABA_ARRAY< Type >::ABA_ARRAY ( ABA_GLOBAL glob,
int  size,
Type  init 
)

A constructor with initialization.

Parameters:
glob A pointer to the corresponding global object.
size The length of the array.
init The initial value of all elements of the array.

template<class Type>
ABA_ARRAY< Type >::ABA_ARRAY ( ABA_GLOBAL glob,
const ABA_BUFFER< Type > &  buf 
)

A constructor.

Parameters:
glob A pointer to the corresponding global object.
buf The array receives the length of this buffer and all buffered elements are copied to the array.

template<class Type>
ABA_ARRAY< Type >::ABA_ARRAY ( const ABA_ARRAY< Type > &  rhs  ) 

The copy constructor.

Parameters:
rhs The array being copied.

template<class Type>
ABA_ARRAY< Type >::~ABA_ARRAY (  ) 

The destructor.


Member Function Documentation

template<class Type>
const ABA_ARRAY<Type>& ABA_ARRAY< Type >::operator= ( const ABA_ARRAY< Type > &  rhs  ) 

The assignment operator can only be used for arrays with equal length.

Returns:
A reference to the array on the left hand side.
Parameters:
rhs The array being assigned.

template<class Type>
const ABA_ARRAY<Type>& ABA_ARRAY< Type >::operator= ( const ABA_BUFFER< Type > &  rhs  ) 

To assign an object of the class ABA_BUFFER to an object of the class ABA_ARRAY the size of the left hand side must be at least the size of rhs. Then all buffered elements of rhs are copied.

Returns:
A reference to the array on the left hand side.
Parameters:
rhs The buffer being assigned.

template<class Type>
Type& ABA_ARRAY< Type >::operator[] ( int  i  ) 

The operator [].

Returns:
The i-th element of the array.
Parameters:
i The element being accessed.

template<class Type>
const Type& ABA_ARRAY< Type >::operator[] ( int  i  )  const

The operator [] is overloaded for constant use.

template<class Type>
void ABA_ARRAY< Type >::copy ( const ABA_ARRAY< Type > &  rhs  ) 

Copies all elements of rhs.

The difference to the operator = is that also copying between arrays of different size is allowed. If necessary the array on the left hand side is reallocated.

Parameters:
rhs The array being copied.

template<class Type>
void ABA_ARRAY< Type >::copy ( const ABA_ARRAY< Type > &  rhs,
int  l,
int  r 
)

This version of the function copy() copies the elements rhs[l], rhs[l+1],, rhs[r] into the components 0,,r-l of the array.

If the size of the array is smaller than r-l+1 storage is reallocated.

Parameters:
rhs The array that is partially copied.
l The first element being copied.
r the last element being copied.

template<class Type>
void ABA_ARRAY< Type >::leftShift ( ABA_BUFFER< int > &  ind  ) 

Removes the components listed in ind by shifting the remaining components to the left.

Memory management of the removed components must be carefully implemented by the user of this function to avoid memory leaks.

Parameters:
ind The compenents being removed from the array.

template<class Type>
void ABA_ARRAY< Type >::leftShift ( ABA_ARRAY< bool > &  remove  ) 

This version of the function leftShift() removes all components i with marked[i]==true from the array by shifting the other components to the left.

Parameters:
remove The marked components are removed from the array.

template<class Type>
void ABA_ARRAY< Type >::set ( int  l,
int  r,
Type  val 
)

Assigns the same value to a subset of the components of the array.

Parameters:
l The first component the value is assigned.
r The last component the value is assigned.
val The new value of these components.

template<class Type>
void ABA_ARRAY< Type >::set ( Type  val  ) 

This version of the function set() initializes all components of the array with the same value.

Parameters:
val The new value of all components.

template<class Type>
int ABA_ARRAY< Type >::size (  )  const

Returns:
The length of the array.

template<class Type>
void ABA_ARRAY< Type >::realloc ( int  newSize  ) 

The length of an array can be changed with the function realloc(). If the array is enlarged all elements of the old array are copied and the values of the additional new elements are undefined. If the array is shortened only the first newSize elements are copied.

Parameters:
newSize The new length of the array.

template<class Type>
void ABA_ARRAY< Type >::realloc ( int  newSize,
Type  init 
)

Is overloaded such that also an initialization with a new value of the elements of the array after reallocation is possible.

Parameters:
newSize The new length of the array.
init The new value of all components of the array.

template<class Type>
void ABA_ARRAY< Type >::rangeCheck ( int  i  )  const [private]

Stops the program with an error message if the index i is not within the bounds of the array.


Friends And Related Function Documentation

template<class Type>
ostream& operator<< ( ostream &  out,
const ABA_ARRAY< Type > &  array 
) [friend]

The output operator writes first the number of the element and a ':' followed by the value of the element line by line to the stream out.

Returns:
A reference to the output stream.
Parameters:
out The output stream.
array The array being output.


Member Data Documentation

template<class Type>
ABA_GLOBAL* ABA_ARRAY< Type >::glob_ [private]

A pointer to the corresponding global object.

Definition at line 257 of file array.h.

template<class Type>
int ABA_ARRAY< Type >::n_ [private]

The length of the array.

Definition at line 261 of file array.h.

template<class Type>
Type* ABA_ARRAY< Type >::a_ [private]

The /-style array storing the elements of the ABA_ARRAY.

Definition at line 265 of file array.h.


The documentation for this class was generated from the following file:
Generated on Tue Aug 14 18:09:56 2007 for ABACUS by  doxygen 1.5.1