C++ 11 feature: C++ Multithreading Tutorial: Attaching and detaching threads in C++
In the first 2 chapters we saw an introduction and different ways to create a thread in C++. In this chapter we shall see ways to attach and detach a thread. Joining a thread using “join()”. Why there is a need to call join()? Once we create a thread, the main program needs to wait […]
Cpp Multi-Threading : Different ways to create a thread in C++
In the previous chapter we saw an introduction to threads and how thread is usedul to increase the execution time. In this chapter we shall see in how many ways we can create a thread. There are 5 different ways to create a thread: 1. Function Pointers 2. Lambda Functions 3. Functors 4. Member Functions […]
Cpp Multi-Threading Introduction
Introduction: A thread is a smallest unit of program execution. These threads can run in parallel and can increase efficiency and decrease execution time of a program. A thread reside inside of a process. In these multi threading chapters, it deals with C++ threading concepts rather than OS threading concepts. Every process by default will […]
CPP STL Tutorial : C++ Binary search operation that can be performed on containers
Binary search can be performed on sorted data. lower_bound : It will return an iterator pointing to the first element in the range [first,last) which does not compare less than val. upper_bound : It will return an iterator pointing to the first element in the range [first,last) which compares greater than val. equal_range : It […]
CPP STL Tutorial : C++ Min/Max operation that can be performed on containers
min : It will return the smallest max : It will return the largest minmax : It will return smallest and largest elements min_element : It will return smallest element in range max_element : It will return largest element in range minmax_element : It will return smallest and largest elements in range To use these […]
CPP STL Tutorial : C++ Heap operation that can be performed on containers
To use these heap operations, below header should be included: #include <algorithm> push_heap : It will push element into heap range pop_heap : It will pop element from heap range make_heap : It will make heap from range sort_heap : It will sort elements of heap is_heap : It will test if range is […]
CPP STL Tutorial: C++ Sorting operation that can be performed on containers
Below are some of the sorting operations that can be performed on STL containers. sort : Sort elements in range stable_sort : Sort elements preserving order of equivalents partial_sort : Partially sort elements in range partial_sort_copy : Copy and partially sort range is_sorted :Check whether range is sorted is_sorted_until : Find first unsorted element […]
CPP STL Tutorial : C++ Partitions operation algorithms
Below are the functions that are used for partition operations: is_partitioned [C++11] : Test whether range is partitioned partition : Partition range in two stable_partition : Partition range in two – stable ordering partition_copy [C++11] : Partition range into two partition_point [C++11] : Get partition point #include <iostream> #include <unordered_map> #include <algorithm> //for more tutorials […]
CPP STL Tutorial : C++ Modifying sequence operations
Below are the some of the member functions for modifying operations: copy : It is used to copy range of elements copy_n : It is used to copy elements move : It is used to move range of elements move_backward : It is used to move range of elements backward replace : It is […]
CPP STL Tutorial : C++ Non modifying sequence operation algorithms
Below are the operations that are used to perform on STL containers. Most of the functions are function template. Hence they can be used to work with primitive and also user defined data types. To use these algorithms, below header should be included: #include <algorithm> all_of : Test condition on all elements […]