Data collections are structures that allow you to store and organize sets of related elements of the same type in a single container.
In your daily life, you constantly use the concept of “collection”. Imagine a moment when talking 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, which is a collection of cards.
All the elements of a deck are of the same type (they are a card). However, at the same time, they all have different properties (the color, the number).
Collections allow you to organize elements in a structured way, which makes it easier to manipulate and access them. Normally, you will be able to perform operations such as adding, removing, searching, and modifying elements, using methods and functions specific to each collection.
In programming, collections are very useful and common. For example, think of the items a customer has in their shopping cart. Or the students who are part of a class in a course. 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 existing collections 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 are as follows: