O'Reilly logo

Mac Programming for Absolute Beginners by Wallace Wang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Dictionaries and Sets

When you store data in an array, you can retrieve it by searching for that specific data or by keeping track of the index position of that data. Since searching for data or storing index positions of data can be cumbersome, there are two other data structures you can use called a dictionary and a set.

Dictionaries act like arrays, but they contain a paired key for each stored value, allowing you to search for a stored value just by knowing its key. Sets make it easy to compare lists and are useful for grouping items and determining whether one set is a subset or intersection of another set.

In this chapter, we explore the ins and outs of both of these data structures.

Dictionary Basics

A dictionary stores two chunks ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required