Home c++ How to implement open hashing?

How to implement open hashing?

Author

Date

Category

before that dealt with closed hashing, everything understood, there is a function that, if the cell is busy calculates a new address by testing. Now I want to try to make open hash. Nowhere can I find exactly the code in C++ with the implementation of open hashing, which is the code itself. In words, I understand that each cell has its own array of elements where elements are inserted during collision, but I do not know how to implement on C++.


Answer 1

something like that (but here is a list for storing collisions, not an array):
TEMPLATE & LT; TYPENAME T, TYPENAME K & GT;
Class Cchash.
{
Private:
  INT HASH (int key); // Hatch feature
  List & LT; T, K & GT; * LIST; // List for storage of collisions
Public:
  T & amp; at (k key) override; // Access by key
  Void Add (K Key, T Value) Override; // Addition
  Void Remove (K Key) Override; // Removal
}
TEMPLATE & LT; TYPENAME T, TYPENAME K & GT;
T & amp; CCHASH & LT; T, K & GT; :: AT (K Key)
{
  RETURN LIST [THIS- & GT; HASH (Key)]. AT (Key);
}
TEMPLATE & LT; TYPENAME T, TYPENAME K & GT;
Void CCHASH & LT; T, K & GT; :: Add (K Key, T Value)
{
  List [this- & gt; hash (key)]. Add (Key, Value);
}
TEMPLATE & LT; TYPENAME T, TYPENAME K & GT;
Void CCHASH & LT; T, K & GT; :: REMOVE (K KEY)
{
  List [this- & gt; hash (key)]. Remove (Key);
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions