vector.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _PVFMM_VECTOR_HPP_
  2. #define _PVFMM_VECTOR_HPP_
  3. #include <pvfmm/common.hpp>
  4. #include <vector>
  5. #include <cstdlib>
  6. #include <stdint.h>
  7. namespace pvfmm {
  8. template <class ValueType> class Vector {
  9. public:
  10. typedef ValueType ValType;
  11. Vector();
  12. Vector(Long dim_, Iterator<ValueType> data_ = Iterator<ValueType>(NULL), bool own_data_ = true);
  13. Vector(const Vector& V);
  14. Vector(const std::vector<ValueType>& V);
  15. ~Vector();
  16. void Swap(Vector<ValueType>& v1);
  17. void ReInit(Long dim_, Iterator<ValueType> data_ = NULL, bool own_data_ = true);
  18. void Write(const char* fname) const;
  19. Long Dim() const;
  20. Long Capacity() const;
  21. void SetZero();
  22. Iterator<ValueType> Begin();
  23. ConstIterator<ValueType> Begin() const;
  24. void PushBack(const ValueType& x);
  25. Vector& operator=(const Vector& V);
  26. Vector& operator=(const std::vector<ValueType>& V);
  27. ValueType& operator[](Long j);
  28. const ValueType& operator[](Long j) const;
  29. private:
  30. Long dim;
  31. Long capacity;
  32. Iterator<ValueType> data_ptr;
  33. bool own_data;
  34. };
  35. template <class ValueType> std::ostream& operator<<(std::ostream& output, const Vector<ValueType>& V);
  36. } // end namespace
  37. #include <pvfmm/vector.txx>
  38. #endif //_PVFMM_VECTOR_HPP_