Record* Hash::findRecord(Key* key){ int bucketNumber = this->hashTable->getBlock(this->hashKey(key)); Bucket* bucket = this->readBucket(bucketNumber); Record* record = bucket->find(key); if(record) record = record->clone(); delete bucket; return record; }
void Hash::reHashRecords(Bucket* bucket, int bucketNumber, Bucket* newBucket) { List<Record*>* recordList = bucket->getRecordList(); ListIterator<Record*> it = recordList->getIterator(); Record* auxRecord = NULL; int bucketDestinationNumber = 0; while(it.hasNext()){ auxRecord = it.next(); bucketDestinationNumber = this->hashTable->getBlock(this->hashKey(auxRecord->getKey())); if(bucketDestinationNumber != bucketNumber){ newBucket->insertRecord(auxRecord->clone()); bucket->deleteRecord(auxRecord->getKey()); } } }