Dictionaries and Sets

The current chapter will focus on data structures related to dictionaries and sets. A proper application of these data structures makes it possible to map keys to values and perform fast lookup, as well as make various operations on sets. To simplify the understanding of dictionaries and sets, this chapter will contain illustrations and code snippets.

In the first parts of this chapter, you will learn both non-generic and generic versions of a dictionary, that is, a collection of pairs, each consisting of a key and a value. Then, a sorted variant of a dictionary will be presented, as well. You will also see some similarities between dictionaries and lists.

The remaining part of the chapter will show you how to use hash ...

Get C# Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.