You will very often be using different collections to store and process data in your applications. Swift has three different built-in collection types: arrays, dictionaries, and sets.
The Swift standard library also has many functions for working with these collections, such as sort, find, filter, map, and many others. These functions have very efficient implementations, and you should use them instead of making your own. First, let's take a look at the different collections.
An array is an ordered collection of values that provides access to its elements by indexes. It is a very simple and well-known collection. You would use an array in these situations:
Simple element storage (often add/remove from the end)
Elements need to be ordered
Random access to elements
Arrays are usually implemented as a continuous block of memory in which you store values. Because memory blocks are usually located next to each other, access to elements can usually be transformed...