Category: Programming
Map in C++ STL
Multiset in C++ STL
C++ multisets are STL containers that store elements of the same type in sorted order, where multiple elements can have equivalent values. In other words, duplicate values are allowed. Like C++ sets, the value of each element acts as its own key. Multiset Properties Elements are referenced by their key and not by their absolute position in the container. Elements are stored in a…
Set in C++ STL
Sets are a type of associative containers in which each element has to be unique because the value of the element identifies it. The values are stored in a specific order. The value of the elements in a set cannot be modified once in the container (the elements are always const), but they can be inserted or…
Stack in C++ STL
Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, Where insertion and deletion is always performed at the top of the stack. For creating a stack, we must include the <stack> header file in our code. We then use this syntax to define the std::stack: Functions of stack: empty…
Priority Queue in C++ STL
Priority queues are a type of container adapters, specifically designed such that the first element of the queue is the greatest of all elements in the queue and elements are in nonincreasing order (hence we can see that each element of the queue has a priority {fixed order}). This context is similar to a heap, where…
Queue in C++ STL
Queues are a type of container adaptors which operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front. Queue functions are: empty() – Returns whether the queue is empty. size() – Returns the size of the queue. queue::swap() in C++ STL –…
Forward_list in C++ STL
Forward_list in STL implements singly linked list. Introduced from C++11, forward list are more useful than other containers in insertion, removal and moving operations (like sort) and allows time constant insertion and removal of elements. It differs from list by the fact that forward_list keeps track of location of only next element while list keeps track to both…
Array class in C++ STL
Arrays are fixed-size sequence containers: they hold a specific number of elements ordered in a strict linear sequence. The introduction of array class from C++11 has offered a better alternative for C-style arrays. The advantages of array class over C-style array are :- Array classes knows its own size, whereas C-style arrays lack this property….
Deque in C++ STL
Double ended queues are sequence containers with the feature of expansion and contraction (fast insertion and deletion) on both the ends. Double Ended Queues are basically an implementation of the data structure double ended queue.Although we can also use vector container for the insertion and deletion at both of its ends, but insertion and deletion…