title: Set vs. Multiset
body: <p>I'd like to store (about 100 to 1000) different relations of type <code>&lt;Object A, Relation R, Object B&gt;</code> in a set or multiset. I'd like to be able to search for <code>A</code> and <code>(A,R)</code>, but not for <code>(A,R,B)</code> (and there will be only a few (&lt;5) relations with the same <code>A</code> and <code>R</code>, so linear search if fine then).</p>
  
  <p>Is it better to store the relations in a set (ordered by <code>A</code>, <code>R</code> and <code>B</code>) or to store them in a multiset ordered by <code>A</code> and <code>R</code>?</p>
  
  <p>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.)</p>
  
  <p>Thanks,
  Ragnar</p>