Sets
Another data structure from Chapter 6, Dictionaries and Sets, is a set, which is a collection of distinct objects without duplicated elements and without any particular order. Therefore, you can only get to know whether a given element is in the set or not. The sets are strictly connected with mathematical models and operations, such as union, intersection, subtraction, and symmetric difference.
The exemplary sets, storing data of various types, are shown as follows:
Figure 10.7 – Illustration of sets with integer and string values
While developing applications in the C# language, you can benefit from high-performance set-related operations provided by the HashSet
class. As an example, you saw how to create a system that handles one-time promotional coupons and allows you to check whether the scanned one was already used. Another example was the reporting service for the system of a SPA center with four swimming pools. By using sets, you...