Count repeated members with setMultiplicity
setMultiplicity measures how often a member occurs in a multiset-like collection. It retains frequency information that ordinary set operations discard.
When it helps
Use it for inventory counts, repeated observations, and bag comparisons. Contrast setDistinct, which keeps only membership, and mode, which identifies the most frequent value.
Caveats
Define equality consistently before counting, especially for objects and rounded numeric data. Use count for total entries and setSize for distinct cardinality; those answer different questions.