Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <vector>
- #include <iostream>
- using namespace std;
- template <typename Type > class BinLattice //cette classe doit etre de type Template
- {
- public :
- void SetN(int _N)
- {
- this->N = _N;
- // resize() is used here to resize the vector Lattice to the N+1 size
- Lattice.resize(N + 1);
- for (int n = 0; n < N; n++)
- {
- // sets the size of inner vector Lattice[n] to n+1
- // the number of nodes a time n
- Lattice[n].resize(n + 1);
- }
- }
- void SetNode(int n, int i, Type x)
- {
- Lattice[n][i] = x;
- }
- double GetNode(int n, int i)
- {
- return Lattice[n][i];
- }
- void Display()
- {
- for (int n = 0; n <= N; n++)
- {
- for (int i = 0; i <= n; i++)
- {
- cout << "[" << GetNode(n, i) << "]" << " "; // à voir en temps voulu
- }
- }
- cout << endl;
- }
- private :
- int N; // number of time steps in the bin tree
- vector<vector<Type>> Lattice;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement