Fixin map

This commit is contained in:
IlushaShurupov 2023-08-11 16:21:30 +03:00 committed by Ilya Shurupov
parent 259bf5a485
commit f5e9b041cd
2 changed files with 8 additions and 3 deletions

View file

@ -41,7 +41,7 @@ namespace tp {
private: private:
tAllocator mAlloc; tAllocator mAlloc;
Node** mTable; Node** mTable = nullptr;
ualni mNSlots = 0; ualni mNSlots = 0;
ualni mNEntries = 0; ualni mNEntries = 0;
@ -181,6 +181,10 @@ namespace tp {
mTable = newTable(mNSlots); mTable = newTable(mNSlots);
} }
Map(const Map& in) {
this->operator=(in);
}
Node** buff() const { Node** buff() const {
return mTable; return mTable;
} }
@ -202,8 +206,9 @@ namespace tp {
if (!mTable[idx] || isDeletedNode(mTable[idx])) { if (!mTable[idx] || isDeletedNode(mTable[idx])) {
mTable[idx] = newNode(key, val); mTable[idx] = newNode(key, val);
mNEntries++; mNEntries++;
} } else {
mTable[idx]->val = val; mTable[idx]->val = val;
}
if ((halnf) mNEntries / mNSlots > maxLoadFactor()) { if ((halnf) mNEntries / mNSlots > maxLoadFactor()) {
rehash(); rehash();
} }

View file

@ -8,5 +8,5 @@ This grammar wil produce text in the form: TODO
Start A Start A
/* Production rule */ /* Production rule */
A : [ ID ]; A : [ ID ] [ IS ] [ IDs ];