#ifndef ROW_CPP
#define ROW_CPP
#include <cstdint>
#include <iostream>

#include "sorting_algorithms.hpp"
#include "hw1.h"

using namespace std;

//constructor vasikos
template <typename T>
Row<T>::Row(T* s, uint32_t size)
{
int n = size;
 p = new T[n];
    for (uint32_t i = 0; i < n; ++i)
      p[i] = s[i];
}

//destructor
template <typename T>
Row<T>::~Row()
{
delete[] p;
}

//copy constructor  
template <typename T>
Row<T>::Row(const Row<T>& neostixio)
{
   n = neostixio.n;
   p = new T[n];  
     for (uint32_t i = 0; i < n; ++i)
       p[i] = neostixio.p[i];
}



//deep copy
template <typename T>
Row<T>& Row<T>::operator=(const Row<T>& neostixio)
{
 if (this != &neostixio)
 {
       delete[] p;
      n = neostixio.n;
      p = new T[n];
      
       for (uint32_t i = 0; i < n; ++i)
         p[i] = neostixio.p[i];
 }
           return *this;
                }
                
template <typename T>
T& Row<T>::operator[](uint32_t index)
{
 	return p[index];
}
template <typename T>
T& Row<T>::at(uint32_t index) 
{
if(index>=n) 
{
   cout<<"out of range"<<endl;
}
     else return p[index];
}
template<typename T>
ostream& operator << (ostream& os, const Row<T>& r)
{
  for(uint32_t i=0; i < r.n; i++) 
  {
  os << r.p[i];
  if (i!=r.n - 1 ) os <<" ";
  } return os;
}
template<typename T>
istream& operator>>(istream& is, Row<T>& r)
{
  for (uint32_t i = 0; i < r.n; i++)
        is >> r.p[i];
         return is;
}

#endif
