HashSet
HashSet<T> is a collection that stores unique elements, automatically removing duplicates. It does not guarantee element order, and the element type T must implement the Hashable and Equatable<T> interfaces.
Use add to add elements (no effect if already exists), contains to check if an element exists, and remove to delete a specific element. HashSet is an ideal choice when you need fast membership testing or automatic deduplication.
The code on the right creates a tag set, demonstrating the behavior of adding duplicate elements, membership checking, element deletion, and iteration. Note that the iteration order may differ from the insertion order.
Try running the code to observe the change in set size after adding the duplicate tour, and whether the iteration order matches the insertion order.