Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Header.h"
- void HashMap::init()
- {
- vect = new Node*[MAX_DIM];
- for (int i = 0; i < MAX_DIM; i++)
- {
- vect[i] = NULL;
- }
- }
- int HashMap::HashFunction(string _key)
- {
- int index;
- int sum = sizeof(_key);
- index = sum%MAX_DIM;
- return index;
- }
- void HashMap::afisare()
- {
- for (int i = 0; i < MAX_DIM; i++)
- {
- if (&vect[i] != NULL)
- {
- cout << "Nume produs: " << vect[i]->name << endl << "Pret: " << vect[i]->pret << endl;
- }
- }
- }
- void HashMap::insert(string _data, int _pret)
- {
- int index = this->HashFunction(_data);
- auto name = new char[sizeof(_data)];
- //de aici incepe sa crape cred
- strcpy_s(vect[index]->name,sizeof(name),name);
- vect[index]->pret = _pret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement