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 "../share/Common.hxx"
00023 #include "../share/Properties.hxx"
00024 #include "../share/Storage.hxx"
00025 #include "../share/Errors.hxx"
00026 #include "../share/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(const 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, VectFull, Allocator>: public Vector_Base<T, Allocator>
00092 {
00093
00094 public:
00095 typedef typename Allocator::value_type value_type;
00096 typedef typename Allocator::pointer pointer;
00097 typedef typename Allocator::const_pointer const_pointer;
00098 typedef typename Allocator::reference reference;
00099 typedef typename Allocator::const_reference const_reference;
00100
00101 typedef VectFull storage;
00102
00103
00104 private:
00105
00106
00107 public:
00108
00109 explicit Vector() throw();
00110 explicit Vector(int i);
00111 Vector(int i, pointer data);
00112 Vector(const Vector<T, VectFull, Allocator>& A);
00113
00114
00115 ~Vector();
00116 void Clear();
00117
00118
00119 void Reallocate(int i);
00120 void Resize(int i);
00121 void SetData(int i, pointer data);
00122 template <class Allocator0>
00123 void SetData(const Vector<T, VectFull, Allocator0>& V);
00124 void Nullify();
00125
00126
00127 reference operator() (int i);
00128 #ifndef SWIG
00129 const_reference operator() (int i) const;
00130 Vector<T, VectFull, Allocator>& operator= (const Vector<T, VectFull,
00131 Allocator>& X);
00132 #endif
00133 void Copy(const Vector<T, VectFull, Allocator>& X);
00134 void Append(const T& x);
00135 template<class T0>
00136 void PushBack(const T0& x);
00137 template<class Allocator0>
00138 void PushBack(const Vector<T, VectFull, Allocator0>& X);
00139
00140
00141 int GetDataSize();
00142
00143
00144 void Zero();
00145 void Fill();
00146 template <class T0>
00147 void Fill(const T0& x);
00148 #ifndef SWIG
00149 template <class T0>
00150 Vector<T, VectFull, Allocator>& operator= (const T0& X);
00151 #endif
00152 template <class T0>
00153 Vector<T, VectFull, Allocator>& operator*= (const T0& X);
00154 void FillRand();
00155 void Print() const;
00156
00157
00158 value_type GetNormInf() const;
00159 int GetNormInfIndex() const;
00160
00161
00162 void Write(string FileName, bool with_size = true) const;
00163 void Write(ostream& FileStream, bool with_size = true) const;
00164 void WriteText(string FileName) const;
00165 void WriteText(ostream& FileStream) const;
00166 void Read(string FileName, bool with_size = true);
00167 void Read(istream& FileStream, bool with_size = true);
00168 void ReadText(string FileName);
00169 void ReadText(istream& FileStream);
00170 };
00171
00172 #ifndef SWIG
00173 template <class T, class Storage, class Allocator>
00174 ostream& operator << (ostream& out,
00175 const Vector<T, Storage, Allocator>& V);
00176 #endif
00177
00178
00179 }
00180
00181 #define SELDON_FILE_VECTOR_HXX
00182 #endif