Tag c++

C++ Iterator

C++ Iterators Iterators are used to access and iterate through elements of data structures (vectors, sets, etc.), by “pointing” to them. It is called an “iterator” because “iterating” is the technical term for looping. To iterate through a vector, look…

C++ Maps

C++ Map A map stores elements in “key/value” pairs. Elements in a map are: Accessible by keys (not index), and each key is unique. Automatically sorted in ascending order by their keys. To use a map, you have to include…

C++ Sets

C++ Set A set stores unique elements where they: Are sorted automatically in ascending order. Are unique, meaning equal or duplicate values are ignored. Can be added or removed, but the value of an existing element cannot be changed. Cannot…

C++ Deque

C++ Deque In the previous page, your learned that elements in a queue are added at the end and removed from the front. A deque (stands for double-ended queue) however, is more flexible, as elements can be added and removed…

C++ Queues

C++ Queue A queue stores multiple elements in a specific order, called FIFO. FIFO stands for First in, First Out. To visualize FIFO, think of a queue as people standing in line in a supermarket. The first person to stand…

C++ Stacks

C++ Stack A stack stores multiple elements in a specific order, called LIFO. LIFO stands for Last in, First Out. To vizualise LIFO, think of a pile of pancakes, where pancakes are both added and removed from the top. So…

C++ List

C++ List A list is similar to a vector in that it can store multiple elements of the same type and dynamically grow in size. However, two major differences between lists and vectors are: You can add and remove elements…

C++ Vectors

C++ Vector A vector in C++ is like a resizable array. Both vectors and arrays are data structures used to store multiple elements of the same data type. The difference between an array and a vector, is that the size…

C++ Data Structures and STL

Data Structures Data structures are used to store and organize data. An array is an example of a data structure, which allows multiple elements to be stored in a single variable. C++ includes many other data structures as well, each…