I want to store a number of participants for a meeting. The order of them is not important. The only thing I want to make sure is, that I will be able to add and remove participants, use filter functions (and alike) and get their number. Also duplicates are not allowed.I started using List for the method signature, but now I wonder if I should accept a more abstract type. I saw types like Traversable, TraversableLike, Iterable and IterableLike.The number of participants will be rather low, usually below 100. Changes will be made occasionally. The participants are immutable (but they have mutable properties e.g. a List of actions they performed for that meeting).What would be the appropriate abstraction level for my case?
What Scala type to use for a list of meeting participants
scala;data types;collections
You mentioned in your comments that your requirements include that:A) You must be able to add and remove elements from the collection.B) The order of the elements is not important.C) Duplicate entries are not allowed.I would suggest using an immutable Set. It should have effectively constant time additions, removals, and lookups, and will automatically prevent the addition of duplicates. This is probably a better fit than a List, which in Scala requires linear time to update, append to, or lookup in, as it is singly linked and can only be accessed starting from the head.The syntax for adding and removing from an immutable set is fairly nice as well.val xs = Set(alice, bob)val xs2 = xs + carl              // Set(alice, bob, carl)val xs3 = xs2 -- Set(alice, bob) // Set(carl)You also get all your typical set operations, like unions, intersects, etc.As with anything, if you have a large enough set of data that performance really matters, benchmark your results.Reference: Performance Characteristcs of Scala Collections