I need a way of storing sets of arbitrary size for fast query later on. I\'ll be needing to query the resulting data structure for subsets or sets that are already stored.
How about having an inverse index built of hashes?
Suppose you have your values int A
, char B
, bool C
of different types. With std::hash
(or any other hash function) you can create numeric hash values size_t Ah, Bh, Ch
.
Then you define a map that maps an index to a vector of pointers to the tuples
std::map > mymap;
or, if you can use global indices, just
std::map > mymap;
For retrieval by queries X
and Y
, you need to
Xh
and Yh
mymap
mymap[Xh]
and mymap[Yh]