I'd like to store (about 100 to 1000) different relations of type <Object A, Relation R, Object B>
in a set or multiset. I'd like to be able to search for A
and (A,R)
, but not for (A,R,B)
(and there will be only a few (<5) relations with the same A
and R
, so linear search if fine then).
Is it better to store the relations in a set (ordered by A
, R
and B
) or to store them in a multiset ordered by A
and R
?
Edit: I've looked into hash tables, but their iteration isn't as fast as (ordered) set iteration, and the pattern matching requires a lot of iteration too. (It will have to search once to find the start of the iteration and then iterate until all relations with the same object A are done.)
Thanks, Ragnar