Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <exception>
- typedef int TElem;
- #define NULL_TELEM 0
- const float alpha = 0.4;
- const long double A = 0.6180339887;
- class Matrix {
- private:
- int nrX, nrY, size, capacity;
- struct MatrixElement {
- int line = -1, column = -1;
- TElem value = NULL_TELEM;
- };
- MatrixElement* hashTable;
- void rehash();
- int hash(int i, int j) const;
- int probing(int x) const;
- public:
- //constructor
- //throws exception if nrLines or nrCols is negative or zero
- Matrix(int nrLines, int nrCols);
- //returns the number of lines
- int nrLines() const;
- //returns the number of columns
- int nrColumns() const;
- //returns the element from line i and column j (indexing starts from 0)
- //throws exception if (i,j) is not a valid position in the Matrix
- TElem element(int i, int j) const;
- //modifies the value from line i and column j
- //returns the previous value from the position
- //throws exception if (i,j) is not a valid position in the Matrix
- TElem modify(int i, int j, TElem e);
- ~Matrix();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement