00001
00034 #ifndef ABA_ARRAY_H
00035 #define ABA_ARRAY_H
00036 #include <iostream>
00037 using namespace std;
00038
00039 #include "abacus/global.h"
00040 #include "abacus/buffer.h"
00041
00042 #ifdef ABACUS_PARALLEL
00043 class MESSAGE;
00044 #endif
00045
00046 #ifdef ABACUS_NEW_TEMPLATE_SYNTAX
00047 template<class Type>
00048 class ABA_ARRAY;
00049 template<class Type>
00050 ostream& operator<< (ostream& out, const ABA_ARRAY<Type> &array);
00051 #endif
00052
00053 template <class Type> class ABA_ARRAY : public ABA_ABACUSROOT {
00054 public:
00055
00061 ABA_ARRAY(ABA_GLOBAL *glob, int size);
00062
00069 ABA_ARRAY(ABA_GLOBAL *glob, int size, Type init);
00070
00077 ABA_ARRAY(ABA_GLOBAL *glob, const ABA_BUFFER<Type> &buf);
00078
00083 ABA_ARRAY(const ABA_ARRAY<Type> &rhs);
00084
00086 ~ABA_ARRAY();
00087 #ifdef ABACUS_PARALLEL
00088
00094 ABA_ARRAY(const ABA_GLOBAL *glob, ABA_MESSAGE &msg);
00095
00100 void pack(ABA_MESSAGE &msg) const;
00101
00109 void pack(ABA_MESSAGE &msg, int nPacked) const;
00110 #endif
00111
00118 const ABA_ARRAY<Type>& operator=(const ABA_ARRAY<Type>& rhs);
00119
00128 const ABA_ARRAY<Type>& operator=(const ABA_BUFFER<Type>& rhs);
00129 #ifdef ABACUS_NEW_TEMPLATE_SYNTAX
00130
00140 friend ostream& operator<< <> (ostream&, const ABA_ARRAY<Type> &);
00141 #else
00142
00152 friend ostream& operator<< (ostream& out, const ABA_ARRAY<Type> &array);
00153 #endif
00154
00161 Type& operator[](int i);
00162
00166 const Type& operator[](int i) const;
00167
00177 void copy(const ABA_ARRAY<Type>& rhs);
00178
00189 void copy(const ABA_ARRAY<Type>& rhs, int l, int r);
00190
00201 void leftShift(ABA_BUFFER<int> &ind);
00202
00210 void leftShift(ABA_ARRAY<bool> &remove);
00211
00218 void set(int l, int r, Type val);
00219
00225 void set(Type val);
00226
00229 int size() const;
00230
00238 void realloc(int newSize);
00239
00247 void realloc(int newSize, Type init);
00248
00249 private:
00250
00254 void rangeCheck(int i) const;
00257 ABA_GLOBAL *glob_;
00258
00261 int n_;
00262
00265 Type *a_;
00266 };
00267
00268 #include "abacus/array.inc"
00269
00270 #endif // !ABA_ARRAY_H
00271