Two-key hash table

I have a large amount of data that I want to have access in two ways. I would like constant time to be searched based on any key, constantly setting the time with one key and constantly deleting time with the other. Is there such a data structure and can I build it using data structures in tr1 and possibly boost it?

+3
source share
4 answers

Use two parallel hash tables. Make sure the keys are stored inside the element value, because you will need all the keys at the time of deletion.

+4
source

Bloom Filters? O (1), , , -, , , .

+1

, , , -, 2 -. :

Hashtable inHash;
Hashtable outHash;

//Hello myObj example!!
myObj.inKey="one";
myObj.outKey=1;
myObj.data="blahblah...";

//adding stuff
inHash.store(myObj.inKey,myObj.outKey);
outHash.store(myObj.outKey,myObj);

//deleting stuff
inHash.del(myObj.inKey,myObj.outKey);
outHash.del(myObj.outKey,myObj);

//findin stuff

//straight
myObj=outHash.get(1);

//the other way; still constant time

key=inHash.get("one");
myObj=outHash.get(key);

, , .

+1

: "" ... - "". , 100% std:: maps "Node *" Node ( ). ( , ).

, "" -

struct Node
{
    Key key1;
    Key key2;
    Payload data;
    Node *Collision1Prev, *Collision1Next;
    Node *Collision2Prev, *Collision2Next;
};

Node - .

. , , , , -, , .

(, , "" ), (.. , ).

0

Source: https://habr.com/ru/post/1782653/


All Articles