Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Despite what others have written here, I don't think that "index" or "position" has meaning with respect to a set. In mathematical terms, a set exposes only its members and maybe its cardinality. The only meaningful operations involve testing whether an item is a member of the set, and combining or subtracting sets to yield new sets.</p> <p>Some people talk about sets <em>as data structures</em> in looser terms, by facets of being "ordered" or "unordered", and whether they permit duplicates or enforce uniqueness. The former facet distinguishes an array with an <em>O(n)</em> insertion guard, where an attempt to insert an item first scans the existing members to see if the new item exists and, if not, inserts the new item at the end, and a hash table, that <em>might</em> retain such order only within a bucket's chain. A tree such as the Red-Black Tree used by <code>std::set</code> is somewhere in between; its traversal order is deterministic with respect to the <a href="http://en.wikipedia.org/wiki/Strict_weak_ordering" rel="nofollow noreferrer"><em>strict weak order</em></a> imposed by the comparator predicate, but, unlike the array sketched above, it doesn't retain <em>insertion order</em>.</p> <p>The other facet — whether the set permits duplicate elements — is meaningless in mathematics, and is more accurately described as a <em>bag</em>. Such a structure acknowledges the difference between identity and value-based "sameness."</p> <p>Your problem may involve caring about some position; it's not clear what that position means, but I expect you're going to need some data structure separate from <code>std::set</code> to model this properly. Perhaps a <code>std::map</code> mapping from your set of elements to each position would do. That would not guarantee that the positions are unique.</p> <p>It may also help clarify the problem to think how you'd model it as <em>relations</em>, such as in a relational database. What comprises the key? What portions of the entities can vary independently?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload