#ifndef _SCTL_VECTOR_HPP_ #define _SCTL_VECTOR_HPP_ #include SCTL_INCLUDE(mem_mgr.hpp) #include SCTL_INCLUDE(common.hpp) #include #include #include namespace SCTL_NAMESPACE { template class Vector { public: typedef ValueType value_type; typedef ValueType& reference; typedef const ValueType& const_reference; typedef Iterator iterator; typedef ConstIterator const_iterator; typedef Long difference_type; typedef Long size_type; Vector(); Vector(Long dim_, Iterator data_ = NullIterator(), bool own_data_ = true); Vector(const Vector& V); Vector(const std::vector& V); ~Vector(); void Swap(Vector& v1); void ReInit(Long dim_, Iterator data_ = NullIterator(), bool own_data_ = true); void Write(const char* fname) const; void Read(const char* fname); Long Dim() const; Long Capacity() const; void SetZero(); Iterator begin(); ConstIterator begin() const; Iterator end(); ConstIterator end() const; void PushBack(const ValueType& x); // Element access ValueType& operator[](Long j); const ValueType& operator[](Long j) const; // Vector-Vector operations Vector& operator=(const std::vector& V); Vector& operator=(const Vector& V); Vector& operator+=(const Vector& V); Vector& operator-=(const Vector& V); Vector& operator*=(const Vector& V); Vector& operator/=(const Vector& V); Vector operator+(const Vector& V) const; Vector operator-(const Vector& V) const; Vector operator*(const Vector& V) const; Vector operator/(const Vector& V) const; // Vector-Scalar operations template Vector& operator=(VType s); template Vector& operator+=(VType s); template Vector& operator-=(VType s); template Vector& operator*=(VType s); template Vector& operator/=(VType s); template Vector operator+(VType s) const; template Vector operator-(VType s) const; template Vector operator*(VType s) const; template Vector operator/(VType s) const; private: void Init(Long dim_, Iterator data_ = NullIterator(), bool own_data_ = true); Long dim; Long capacity; Iterator data_ptr; bool own_data; }; template Vector operator+(VType s, const Vector& V); template Vector operator-(VType s, const Vector& V); template Vector operator*(VType s, const Vector& V); template Vector operator/(VType s, const Vector& V); template std::ostream& operator<<(std::ostream& output, const Vector& V); } // end namespace #include SCTL_INCLUDE(vector.txx) #endif //_SCTL_VECTOR_HPP_