Using HashSets
The last collection type we'll get our hands on in this chapter is the HashSet. This collection is very different from any other collection type that we've come across: it cannot store duplicate values and is not sorted, meaning its elements are not ordered in any way. Think of HashSets as dictionaries with just keys, instead of key-value pairs.
They can perform set operations and element lookups extremely fast, which we'll explore at the end of this section, and are best suited to situations where the element order and uniqueness are a top priority.
A HashSet variable declaration needs to meet the following requirements:
- The
HashSet
keyword, its element type between left and right arrow characters, and a unique name - The
new
keyword to initialize the HashSet in memory, followed by theHashSet
keyword and element type between arrow characters - A pair of parentheses capped off by a semicolon
In blueprint form, it...