C++

Unordered Map in STL | C++

Unordered maps are associative containers that store elements formed by the combination of a key value and a mapped value, and which allows for fast retrieval of individual elements based on their keys. The elements in the unordered_map are not sorted in any particular order with respect to either their [...]

2019-09-17T23:26:05+05:30Categories: Programming|Tags: |

Map in STL | C++

Maps are used to replicate associative arrays. Maps contain sorted key-value pair, in which each key is unique and cannot be changed, and it can be inserted or deleted but cannot be altered. Value associated with keys can be altered. We can search, remove and insert in a map within [...]

2019-09-17T21:24:15+05:30Categories: Programming|Tags: |

Deque in STL | C++

Double ended queues are sequence containers with the feature of expansion and contraction on both the ends. They are similar to vectors, but are more efficient in case of insertion and deletion of elements. Unlike vectors, contiguous storage allocation may not be guaranteed. Both vectors and deques provide a very similar interface [...]

2019-09-17T21:02:55+05:30Categories: Programming|Tags: |

Array in STL | C++

The array is a container for constant size arrays. This container wraps around fixed size arrays and also doesn’t loose the information of its length when decayed to a pointer. Syntax array<object_type, array_size> array_name; The above code creates an empty array of object_type with maximum size of array_size. Member Functions [...]

2019-09-17T20:35:06+05:30Categories: Programming|Tags: |

Tuple in STL | C++

tuple and pair are very similar in their structure. Just like in pair we can pair two heterogeneous object, in tuple we can pair three heterogeneous objects. The elements of tuples are initialized as arguments in order in which they will be accessed. Operations on tuple get() :- Used to [...]

2019-09-16T23:19:20+05:30Categories: Programming|Tags: |

Pair in STL | C++

The pair container is a simple container defined in <utility> header consisting of two data elements or objects. The first element is referenced as ‘first’ and the second element as ‘second’ and the order is fixed (first, second). Pair is used to combine together two values which may be different in type. [...]

2019-09-16T23:01:25+05:30Categories: Programming|Tags: |

List in STL | C++

Array and Vector are contiguous containers, i.e they store their data on continuous memory, thus the insert operation at the middle of vector/array is very costly (in terms of number of operation and process time) because we have to shift all the elements, linked list overcome this problem. Linked list [...]

2019-09-16T22:03:10+05:30Categories: Programming|Tags: |

Variable Templates | C++

The variable template is one of the major proposals in Standard C++14. The main purpose of the variable template is to simplify definitions and uses of parameterized constants. With variable templates of C++14, manipulation of constant values with various types can be significantly simplified as shown in below example. PI [...]

2019-09-16T20:35:56+05:30Categories: Programming|Tags: |

Move Semantics in C++

Introduction Move semantics in C++ is used to move resources around in an optimal way by avoiding unnecessary copies of temporary objects. C++11 defines two new functions for move semantics : move constructor, and move assignment operator. Copy constructor (and assignment) make a copy of one object to another, while [...]

2020-09-04T13:38:48+05:30Categories: Programming|Tags: |

Exception Handling | C++

Introduction An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of [...]

2019-09-14T11:13:17+05:30Categories: Programming|Tags: |
Go to Top