Data collections are structures that allow you to store and organize sets of elements of the same type and related in a single container.
In your everyday life, you constantly use the concept of a “collection.” Imagine a moment when someone talks about a collection of stamps, or coins, or Star Wars figurines. All of them are sets of elements of the same type.
Another everyday example would be a deck of cards.
All the elements of a deck are of the same type (they are a card). Although, at the same time, they all have different properties (the color, the number).
Collections allow you to organize elements in a structured way, which facilitates their manipulation and access. Typically, you can perform operations such as adding, removing, searching, and modifying elements using specific methods and functions of each collection.
In programming, collections are very useful and common. For example, imagine the items a customer has in their shopping cart. Or the students who are part of a course class. All of these are examples of collections.
In addition to being useful, collections have a great impact on the efficiency of our program. Therefore, it is very important to know the types of collections that exist, and their characteristics, in order to choose the right one for your needs.
Common types of collections
There are several types of collections used in programming, each with its own characteristics and uses. The most common ones are: