Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #pragma once
  2. #include <exception>
  3.  
  4.  
  5. typedef int TElem;
  6.  
  7. #define NULL_TELEM 0
  8. const float alpha = 0.4;
  9. const long double A = 0.6180339887;
  10.  
  11.  
  12.  
  13.  
  14. class Matrix {
  15.  
  16.  
  17.  
  18. private:
  19.  
  20. int nrX, nrY, size, capacity;
  21. struct MatrixElement {
  22. int line = -1, column = -1;
  23. TElem value = NULL_TELEM;
  24.  
  25. };
  26. MatrixElement* hashTable;
  27. void rehash();
  28. int hash(int i, int j) const;
  29. int probing(int x) const;
  30.  
  31. public:
  32.  
  33. //constructor
  34.  
  35. //throws exception if nrLines or nrCols is negative or zero
  36.  
  37. Matrix(int nrLines, int nrCols);
  38.  
  39.  
  40.  
  41. //returns the number of lines
  42.  
  43. int nrLines() const;
  44.  
  45.  
  46.  
  47. //returns the number of columns
  48.  
  49. int nrColumns() const;
  50.  
  51.  
  52.  
  53. //returns the element from line i and column j (indexing starts from 0)
  54.  
  55. //throws exception if (i,j) is not a valid position in the Matrix
  56.  
  57. TElem element(int i, int j) const;
  58.  
  59.  
  60.  
  61. //modifies the value from line i and column j
  62.  
  63. //returns the previous value from the position
  64.  
  65. //throws exception if (i,j) is not a valid position in the Matrix
  66.  
  67. TElem modify(int i, int j, TElem e);
  68.  
  69.  
  70.  
  71.  
  72. ~Matrix();
  73. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement