Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #pragma once
  2. #include <vector>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. template <typename Type > class BinLattice //cette classe doit etre de type Template
  7. {
  8. public :
  9. void SetN(int _N)
  10. {
  11. this->N = _N;
  12. // resize() is used here to resize the vector Lattice to the N+1 size
  13. Lattice.resize(N + 1);
  14. for (int n = 0; n < N; n++)
  15. {
  16. // sets the size of inner vector Lattice[n] to n+1
  17. // the number of nodes a time n
  18. Lattice[n].resize(n + 1);
  19. }
  20. }
  21.  
  22. void SetNode(int n, int i, Type x)
  23. {
  24. Lattice[n][i] = x;
  25. }
  26.  
  27. double GetNode(int n, int i)
  28. {
  29. return Lattice[n][i];
  30. }
  31.  
  32. void Display()
  33. {
  34. for (int n = 0; n <= N; n++)
  35. {
  36. for (int i = 0; i <= n; i++)
  37. {
  38. cout << "[" << GetNode(n, i) << "]" << " "; // à voir en temps voulu
  39. }
  40. }
  41. cout << endl;
  42. }
  43.  
  44. private :
  45. int N; // number of time steps in the bin tree
  46. vector<vector<Type>> Lattice;
  47. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement