00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SELDON_FILE_VECTOR_HXX
00021
00022 #include "../Common/Common.hxx"
00023 #include "../Common/Properties.hxx"
00024 #include "../Common/Storage.hxx"
00025 #include "../Common/Errors.cxx"
00026 #include "../Common/Allocator.hxx"
00027
00028 namespace Seldon
00029 {
00030
00031
00033
00037 template <class T, class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00038 class Vector_Base
00039 {
00040
00041 public:
00042 typedef typename Allocator::value_type value_type;
00043 typedef typename Allocator::pointer pointer;
00044 typedef typename Allocator::const_pointer const_pointer;
00045 typedef typename Allocator::reference reference;
00046 typedef typename Allocator::const_reference const_reference;
00047
00048
00049 protected:
00050 static Allocator vect_allocator_;
00051
00052
00053 protected:
00054
00055 int m_;
00056
00057 pointer data_;
00058
00059
00060 public:
00061
00062 Vector_Base();
00063 explicit Vector_Base(int i);
00064 Vector_Base(Vector_Base<T, Allocator>& A);
00065
00066
00067 ~Vector_Base();
00068
00069
00070 int GetM() const;
00071 int GetLength() const;
00072 int GetSize() const;
00073 pointer GetData() const;
00074 const_pointer GetDataConst() const;
00075 void* GetDataVoid() const;
00076 const void* GetDataConstVoid() const;
00077
00078 };
00079
00080
00081
00082 template <class T, class Allocator>
00083 Allocator Vector_Base<T, Allocator>::vect_allocator_;
00084
00085
00087
00090 template <class T, class Allocator>
00091 class Vector<T, Vect_Full, Allocator>: public Spacetown,
00092 public Vector_Base<T, Allocator>
00093 {
00094
00095 public:
00096 typedef typename Allocator::value_type value_type;
00097 typedef typename Allocator::pointer pointer;
00098 typedef typename Allocator::const_pointer const_pointer;
00099 typedef typename Allocator::reference reference;
00100 typedef typename Allocator::const_reference const_reference;
00101
00102
00103 private:
00104
00105
00106 public:
00107
00108 explicit Vector<T, Vect_Full, Allocator>() throw();
00109 explicit Vector<T, Vect_Full, Allocator>(int i);
00110 Vector<T, Vect_Full, Allocator>(Vector<T, Vect_Full, Allocator>& A);
00111
00112
00113 ~Vector();
00114 void Clear();
00115
00116
00117 void Reallocate(int i);
00118 void SetData(int i, pointer data);
00119 void Nullify();
00120
00121
00122 reference operator() (int i);
00123 const_reference operator() (int i) const;
00124 Vector<T, Vect_Full, Allocator>& operator= (const Vector<T, Vect_Full,
00125 Allocator>& X);
00126 void Copy(const Vector<T, Vect_Full, Allocator>& X);
00127
00128
00129 int GetDataSize();
00130
00131
00132 void Zero();
00133 void Fill();
00134 template <class T0>
00135 void Fill(const T0& x);
00136 template <class T0>
00137 Vector<T, Vect_Full, Allocator>& operator= (const T0& X);
00138 void FillRand();
00139 void Print() const;
00140
00141
00142 value_type GetNormInf() const;
00143 int GetNormInfIndex() const;
00144
00145
00146 void Write(string FileName) const;
00147 void Write(ofstream& FileStream) const;
00148 void WriteText(string FileName) const;
00149 void WriteText(ofstream& FileStream) const;
00150 void Read(string FileName);
00151 void Read(ifstream& FileStream);
00152
00153 };
00154
00155 template <class T, class Storage, class Allocator>
00156 ostream& operator << (ostream& out,
00157 const Vector<T, Storage, Allocator>& V);
00158
00159
00160 }
00161
00162 #define SELDON_FILE_VECTOR_HXX
00163 #endif