We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Category: STL

Iterating over a range of User Defined objects and calling member function using std::for_each

In this article we will discuss how to iterate over a container of user defined objects and call a member function on each of the iterating element.Suppose you have a vector of Employee class objects and you want to call a member function on each of the element in vector. [showads ad=inside_post] Let’s see how …

Iterating over a range of User Defined objects and calling member function using std::for_eachRead More

c++ std::vector and Iterator Invalidation example

In this article we will discuss the iterator invalidation with respect to std::vector in C++. What is Iterator Invalidation? An Iterator becomes invalidate when the container it points to changes its shape internally i.e. move elements from one location to another and the initial iterator still points to old invalid location. Advertisements Iterator invalidation in …

c++ std::vector and Iterator Invalidation exampleRead More

How to use vector efficiently in C++?

We can use vector efficiently by taking care of following points, 1.) Vector will be more efficient if elements are inserted or removed from the back-end only. Advertisements As, vector internally stores all the elements in consecutive memory location. Therefore, if an element is added in middle, then vector right shifts all the right side …

How to use vector efficiently in C++?Read More

What is std::deque and how deque works internally.

deque

In this article we will discuss what is a deque and how it works internally. Deque is a double ended queue container that provides insertion and deletion at both ends i.e. front and back with high performance unlike vector that provides high performance insertion at end i.e. back only. Advertisements [showads ad=inside_post] Also it provides …

What is std::deque and how deque works internally.Read More

deque vs vector : What to choose ?

In this article we will discuss the differences between vector and deque STL Containers. Vector provides insertion and deletion at middle and end only. Whereas, deque provides operations for insertion at front, middle and end. That is, apart from push_back() and pop_back() APIs jus like vector, deque also has push_front() and pop_front() API to add …

deque vs vector : What to choose ?Read More

C++ std::list Tutorial, Example and Usage Details

In this article we will discuss std::list usage details. What is std::list ? std::list is sequential STL container that is internally implemented as doubly linked list. i.e. every element in the list is stored at a seperate memory location i.e. called node and it also contains a pointer to the previous and next node. Advertisements …

C++ std::list Tutorial, Example and Usage DetailsRead More

Different Ways to Initialize a vector in C++

In this article we will discuss different ways to initialize a std::vector in C++. Initializing std::vector elements with same value std::vector<int> vec_1(5, 10); It will create a vector of 5 element and initialize  each element is initialized to 10. Advertisements Initializing std::vector elements with passed argument list std::vector<int> vec_2 = {10,20,30,40,50}; It will create a vector of 5 …

Different Ways to Initialize a vector in C++Read More

STL Algorithm std::unique Tutorial

In this example we will discuss std::unique STL Algorithm. std::unique is a n STL Algorithms that provide a functionality to remove all consecutive duplicate elements from a given range. Advertisements For example, we have an array of elements i.e. 1,2,3,3,3,4,4,5,5 Frequently Asked: STL Algorithm std::unique Tutorial As we can see above there are 4 consecutive …

STL Algorithm std::unique TutorialRead More

10
264.090,65