Junior — Middle
Can you tell me about the types of containers you have worked with or know?
sobes.tech AI
Answer from AI
The C++ standard library provides several core container types that I have used and am familiar with:
- std::vector — a dynamic array that offers fast index access and efficient appending of elements.
- std::list — a doubly linked list, convenient for frequent insertions and deletions in the middle of the collection.
- std::deque — a double-ended queue that allows fast addition and removal of elements at both the front and the back.
- std::set and std::map — associative containers that store unique keys (set) or key-value pairs (map) in sorted order.
- std::unordered_set and std::unordered_map — hash tables for fast key-based access without guaranteed order.
Example of using std::vector:
#include <vector>
#include <iostream>
int main() {
std::vector<int> numbers = {1, 2, 3};
numbers.push_back(4);
for (int num : numbers) {
std::cout << num << " ";
}
return 0;
}
I am also familiar with containers from Boost and Qt, but I most often use the standard ones.