Diffpack Documentation
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Search
very simple vector, only allocation and subscripting.
More...
#include <VecSimplest_Type.h>
Inheritance diagram for VecSimplest(Type)::
List of all members.
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
|
|
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. |
|
|
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. |
|
|
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]
|
|
|
|
checks if the object has compatible size with the object given as argument.
Reimplemented in ArrayGen(Type), and ArrayGenSimplest(Type). |
|
|
See documentation of one of the overloaded functions. |
|
|
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. |
|
|
See documentation of one of the overloaded functions. |
|
|
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]
|
|
|
|
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). |
|
const Type & VecSimplest(Type)::operator() (
|
int i ) const
|
|
|
|
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 )
|
|
|
|
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). |
|
|
returns the length of the vector. |
Member Data Documentation
The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.