Я создал функцию вставки, которая добавляет идентификатор ученика, имя, фамилию и адрес электронной почты в массив связанного списка. Я должен создать другую функцию, которая проверяет, доступен ли определенный студент, и обновлять его электронную почту, но я не знаю, с чего начать с этой функцией
ФАЙЛ ГОЛОВКИ
#pragma once
#include <iostream>
#include <string>
using namespace std;
class HashTable
{
private:
struct HashNode
{
string key;
string value;
HashNode* next;
};
HashNode* table[100];
int currentSize;
int maxSize;
public:
HashTable(int x);
void insert(string ID, string firstName, string lastName, string email);
bool update(string ID, string newEmail);
};
CPP ФАЙЛ
HashTable::HashTable(int x)
{
maxSize = x;
};
void HashTable::insert(string ID, string firstName, string lastName, string email)
{
HashNode x;
x.key = ID;
x.value = firstName + " " + lastName + " " + email;
int index = hash(x.key);
if (*(table + index) == NULL)
{
*(table + index) = new HashNode;
(*(table + index))->key = x.key;
(*(table + index))->value = x.value;
(*(table + index))->next = NULL;
}
else
{
HashNode* temp = *(table + index);
while (temp->next != NULL)
temp = temp->next;
HashNode* newNode = new HashNode;
newNode->key = x.key;
newNode->value = x.value;
newNode->next = NULL;
temp->next = newNode;
temp = NULL;
newNode = NULL;
}
currentSize++;
};