List-based set representation (source code)

= List-based set representation

Represent a <finite set> by a <list> of its elements. Allowing repeated elements makes <set union> cheap by <list concatenation>; imposing uniqueness requires membership checks. A representation sorted by a <total order> and containing no duplicates permits <set union> and <set intersection> by a simultaneous scan in <linear time>. These are different <representation invariants> for the same abstract <set>.