I am trying to make a hash table that takes on a Vector2
as its key and an int as its value, but when I try to insert a key and value pair in its insert function I get an error:
no matching function for call to std::pair<Vector2, int>::pair(const Vector2&, int).
If anyone knows why this is happening and how to fix it, please help.
void HashTable::insert(const Vector2& key, int value)
{
int index = hashFunction(key) % m_buckets.size();
m_buckets.insert(m_buckets.begin() + index, std::make_pair(key, value));
}
I tried to use a different way to insert that is:
m_buckets[index].push_back(make_pair(key, value)
but it only gives me another error:
struct std::pair<Vector2, int> has no member named push.back
Vector2
is a vector class that takes to integers x and y.
std::vector<std::pair<Vector2, int>> m_buckets