olexander_dan

Untitled

May 6th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <fstream>
  4. #include "vList.h"
  5. #include "grRepres.h"
  6. using namespace std;
  7.  
  8. VList::VList(size_t _n) : vList{ new size_t[_n] }, nmax{ _n }, n{ 0 } {}
  9.  
  10. VList::VList(VList&& r) noexcept : nmax{ 0 }, n{ 0 }, vList{ nullptr } {
  11.     nmax = r.nmax;
  12.     n = r.n;
  13.     vList = r.vList;
  14.  
  15.     r.nmax = r.n = 0;
  16.     r.vList = nullptr;
  17. }
  18.  
  19. VList::~VList() {
  20.     delete[]vList;
  21. }
  22.  
  23. void VList::add(size_t v) {
  24.     if (n < nmax)
  25.         vList[n++] = v;
  26. }
  27.  
  28. bool VList::notEmpty() { return n > 0; }
  29.  
  30. void VList::output(ofstream& f) {
  31.     for (size_t i = 0; i < n; ++i)
  32.         f << vList[i] << ' ';
  33. }
Add Comment
Please, Sign In to add comment