Guest User

Untitled

a guest
Apr 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include "Matriz.hpp"
  2. #include "auxiliares.hpp"
  3.  
  4. using namespace std;
  5. using namespace aed2;
  6.  
  7. template<typename T>
  8. Matriz<T>::Matriz(Nat filas, Nat columnas)
  9.     : _filas(filas)
  10.     : _columnas(columnas)
  11.     : _posiciones(_filas)
  12. {
  13.     for(Nat i = 0; i < filas; i++)
  14.     {
  15.         Arreglo<T> af(_columnas);
  16.         af.Definir(i, af);
  17.     }
  18.     _posiciones = af;
  19. }
  20.  
  21. template<typename T>
  22. Nat Matriz<T>::filas()
  23. {
  24.     return _filas;
  25. }
  26.  
  27. template<typename T>
  28. Nat Matriz<T>::columnas()
  29. {
  30.     return _columnas;
  31. }
  32. template<typename T>
  33. bool Matriz<T>::def(Pos pos)
  34. {
  35.     Nat fila = pos.first;
  36.     Nat columna = pos.second;
  37.  
  38.     return _posiciones[fila].definido(columna);
  39. }
  40.  
  41. template<typename T>
  42. T* Matriz<T>::valor(Pos pos)
  43. {
  44.     Nat fila = pos.first;
  45.     Nat columna = pos.second;
  46.  
  47.     return _posiciones[fila][columna];
  48. }
  49.  
  50. template<typename T>
  51. void Matriz<T>::definir(Pos pos, T& valor)
  52. {
  53.     Nat fila = pos.first;
  54.     Nat columna = pos.second;
  55.  
  56.     _posiciones[fila].Definir(columna, valor);
  57.  
  58.  
  59. }
  60.  
  61. template<typename T>
  62. bool Matriz<T>::pertenece(Pos pos)
  63. {
  64.     Nat fila = pos.first;
  65.     Nat columna = pos.second;
  66.  
  67.     return fila < _filas && columna < _columnas;
  68.  
  69. }
Add Comment
Please, Sign In to add comment