Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

VecSimplest(Type) Class Reference

very simple vector, only allocation and subscripting. More...

#include <VecSimplest_Type.h>

Inheritance diagram for VecSimplest(Type)::

ArrayGenSimplest_Type VecSimple_Type VecSimplestH_Type ArrayGenSimple_Type ArrayGenSimple_Type VecSimpleH_Type VecSort_Type ArrayGen_Type ArrayGen_Type Vec_Type ArrayGenSel_Type ArrayGenSel_Type ArrayGen_Type ArrayGenSel_Type List of all members.

Public Methods

 VecSimplest(Type) ()
 VecSimplest(Type) (int length)
 VecSimplest(Type) (Type *a, int n, int base=0)
virtual ~VecSimplest(Type) ()
bool redim (int length)
bool redim (Type *a, int n, int base=0)
bool ok () const
int size () const
bool compatible (const VecSimplest(Type) &X) const
bool indexOk (int i, const char *message=NULL) const
const Type& operator() (int i) const
Type& operator() (int i)
const Type* getPtr0 () const
Type* getPtr0 ()
const Type* getPtr1 () const
Type* getPtr1 ()
 VecSimplest(Type) (const VecSimplest(Type) &v)
void operator= (const VecSimplest(Type) &v)

Static Public Attributes

long nbytes
long nbytes_dealloc
long narrays
long narrays_dealloc
real report_ifgt

Protected Methods

bool makeNew (int length)
Type* allocate (int length)
void deallocate ()
Type* borrow (Type *a, int n, int base=0)

Protected Attributes

Type* A
int length
bool internal

Detailed Description

very simple vector, only allocation and subscripting.

NAME: VecSimplest(Type) - very simple vector, only allocation and subscripting

DESCRIPTION:

The class implements a standard vector type. The public interface consists only of two constructors, a subscripting operator and some size information. In addition, the pointer representation of the vector can be returned from a member function (e.g. when using this vector in a C function). The base is unity. This means that the array entries are "A[1]", "A[2]" and so on up to "A[length]".

More operations, included "print", "fill", "operator=", copy-constructors, "operator<<" etc., can be found in the derived class "VecSimple(Type)". If arithmetic operations have meanings (e.g. when "Type" is "float", "double" or "Complex") one can use the standard class "Vec(Type)" which is derived from "VecSimple(Type)". A general base for the subscripting operator is provided in "ArrayGenSimplest(Type)".

Since no operations, except a constructor without arguments, is assumed to exist for "Type", this vector class can be used as a general class for collecting (complicated) objects in a vector.


Constructor & Destructor Documentation

VecSimplest(Type)::VecSimplest_Type ( )
 

Three constructors are available. The constructor without parameters allocates no memory. To allocate the proper amount of memory at a later stage, the "redim" function can be used. Another constructor takes the number of entries in the vector as parameter and allocates memory for the corresponding vector representation. The third constructor takes a C array and its length and base index as parameters. This makes it easy for the vector to borrow its contents from an already existing C array. The C array will not be deleted by the "VecSimplest" class, but the contents of the array may be changed. Note that "VecSimplest" cannot take a copy of the C array since "operator=" is not required for class "Type". However, one may create a "VecSimple" object from a C array and then copy this class object.

To initialize the vector entries one must use the member function "operator()".

A new feature allows declaration of arrays with zero length.

VecSimplest(Type)::VecSimplest_Type ( int length )
 

See documentation of one of the overloaded constructor.

VecSimplest(Type)::VecSimplest_Type ( Type * a,
int n,
int base = 0 )
 

See documentation of one of the overloaded constructor.

VecSimplest(Type)::~VecSimplest(Type) ( ) [virtual]
 

VecSimplest(Type)::VecSimplest_Type ( const VecSimplest(Type) & v )
 

See documentation of one of the overloaded constructor.


Member Function Documentation

Type * VecSimplest(Type)::allocate ( int length ) [protected]
 

Type * VecSimplest(Type)::borrow ( Type * a,
int n,
int base = 0 ) [protected]
 

bool VecSimplest(Type)::compatible ( const VecSimplest(Type) & X ) const
 

checks if the object has compatible size with the object given as argument.

Reimplemented in ArrayGen(Type), and ArrayGenSimplest(Type).

void VecSimplest(Type)::deallocate ( ) [protected]
 

Type * VecSimplest(Type)::getPtr0 ( )
 

See documentation of one of the overloaded functions.

const Type * VecSimplest(Type)::getPtr0 ( ) const
 

returns access to the internal C array and assumes that the base is 0 (note that internally in this class, the base is 1). The "getPtr0" simply sends the address of the first element in the array. This is the common function for sending a Diffpack vector to a C function requiring a pointer (for a standard C array). Also when a Diffpack vector "v" is to be sent to a Fortran subroutine or function, "v.getPtr0()" is the correct data structure to send.

Type * VecSimplest(Type)::getPtr1 ( )
 

See documentation of one of the overloaded functions.

const Type * VecSimplest(Type)::getPtr1 ( ) const
 

returns access to the internal C array and assumes that the base is 1. The "getPtr1" simply sends the address of the first array element 'minus one'. A common use is when the object is to be transferred to C functions where arrays are assumed to have "[1]" as their first index (e.g., Numerical Recipes routines). Although Fortran arrays usually start with unit base, sending the return value of "getPtr1" to a Fortran subroutine will actually send the address to the array minus one and the calculations will be wrong.

bool VecSimplest(Type)::indexOk ( int i,
const char * message = NULL ) const
 

returns "false" and an error message if the index is illegal, legal indices leads to a "true" return value. There is an optional argument that can be used to give extra information, for example, from which function "indexOk" is called.

Reimplemented in ArrayGenSimplest(Type).

bool VecSimplest(Type)::makeNew ( int length ) [protected]
 

bool VecSimplest(Type)::ok ( ) const
 

returns "true" if the object is in an ok state, that is, if memory is allocated for the vector. In an ok state one can make the call "operator() (1)" (at least one entry is present in the vector).

Type & VecSimplest(Type)::operator() ( int i )
 

Reimplemented in ArrayGen(Type), ArrayGenSimple(Type), and ArrayGenSimplest(Type).

const Type & VecSimplest(Type)::operator() ( int i ) const
 

Reimplemented in ArrayGen(Type), ArrayGenSimple(Type), and ArrayGenSimplest(Type).

void VecSimplest(Type)::operator= ( const VecSimplest(Type) & v )
 

Be aware that "VecSimplest" does not require the "Type" class to have an "operator=". Hence, the copy constructor or the assignment operator has no meaning for "VecSimplest". Since C++ automatically makes such functions if they are not explicitly declared (and such automatically generated functions lead to serious errors in the present case), the functions are declared, but the content is just an error message.

bool VecSimplest(Type)::redim ( Type * a,
int n,
int base = 0 )
 

See documentation of one of the overloaded functions.

Reimplemented in ArrayGen(Type), ArrayGenSel(Type), ArrayGenSimple(Type), ArrayGenSimplest(Type), and Vec(Type).

bool VecSimplest(Type)::redim ( int no_algdofs )
 

changes the dimension ("length") of the vector (only if necessary, that is, if the old length differes from the argument to "redim"). There is also a "redim" function for borrowing a C-array.

Reimplemented in ArrayGen(Type), ArrayGenSel(Type), ArrayGenSimple(Type), ArrayGenSimplest(Type), and Vec(Type).

int VecSimplest(Type)::size ( ) const [inline]
 

returns the length of the vector.


Member Data Documentation

Type * VecSimplest(Type)::A [protected]
 

bool VecSimplest(Type)::internal [protected]
 

int VecSimplest(Type)::length [protected]
 

long VecSimplest(Type)::narrays [static]
 

long VecSimplest(Type)::narrays_dealloc [static]
 

long VecSimplest(Type)::nbytes [static]
 

long VecSimplest(Type)::nbytes_dealloc [static]
 

real VecSimplest(Type)::report_ifgt [static]
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.