“Sorted” sets
The previously described HashSet
class can be understood as a dictionary that stores only keys, without values. So, if there is the SortedDictionary
class, maybe there is also the SortedSet
class? There is! However, can a set be “sorted”? Why is “sorted” written with quotation marks? The answer turns out to be very simple. By definition, a set stores a collection of distinct objects without duplicated elements and without a particular order. If a set does not support order, how can it be “sorted”? For this reason, a “sorted” set can be understood as a combination of HashSet and SortedList, not a set itself.
Imagine a “sorted” set
If you want to better imagine a “sorted” set, recall the previous example related to the game of chance. To facilitate manual comparison of results, both the set of randomly drawn numbers and the set of numbers selected by you can be “...