CodesJava

Easy learning with example program codes

CPP Algorithm

CPP facilitates a number of functions that can be applied on a range of elements. Some of these are:

Binary search

FUNCTION USES
binary_searchTo test if the values in the range exists in a sorted sequence or not.
equal_rangeTo get the subrange for the equal elements.
lower_boundTo get the lower bound element of the range.
 upper_boundTo get the upper bound element of the range.

 

Heap

FUNCTION USES
is_heapTo check whether the range is a heap.
is_heap_untilTo check the position till which a range is a heap.
make_heapTo create a heap.
pop_heapTo pop new elements in the heap.
push_heapTo push new elements in the heap.
sort_heapTo sort the heap.

 

Merge

FUNCTION USES
includesTo check whether the sorted range includes another range or not.
inplace_mergeTo merge two consecutive ranges that are sorted.
mergeTo merge two ranges that are in a sorted order.
set_unionTo get the union of two ranges that is sorted.
set_intersectionTo get the intersection of two ranges that is sorted.
set_differenceTo get the difference of two ranges that is sorted.
set_symmetric_differenceTo get the symmetric difference of two ranges that is sorted.

 

Min/Max

FUNCTION USES
minTo get the smallest element of the range.
maxTo get the largest element of the range.
minmaxTo get the smallest and largest element of the range.
min_elementTo get the smallest element of the range.
max_elementTo get the largest element of the range.
minmax_elementTo get the smallest and largest element of the range.

Modifying sequence operations:

FUNCTION USES
copyTo copy the range of elements.
 copy_n To copy n elements of the range.
copy_ifTo copy the elements of the range if a certain condition is fulfilled.
 copy_backwardTo copy the elements in a backward order.
 fillTo fill the values in the range with a value.
 fill_nTo fill the values in the sequence.
generateTo generate the values of the range.
generate_nTo generate the values of the sequence.
iter_swapTo swap the values of two iterators under reference.
moveTo move the ranges of elements.
move_backwardTo move the range of elements in the backward order.
 replaceTo replace the values in the range with a specific value.
replace_ifTo replace the value of the range if a certain condition is fulfilled.
 replace_copyTo copy the range of values by replacing with an element.
 replace_copy_ifTo copy the range of values by replacing with an element if a certain condition is fulfilled.
remove_copyTo copy the values of the range by removing them.
remove_copy_ifTo copy the values of the range by removing them if a condition is fulfilled.
 reverseTo reverse the range.
reverse_copyTo copy the range by reversing values.
rotateTo rotate the elements of the range in left direction.
rotate_copyTo copy the elements of the range which is rotated left.
 random_shuffleTo shuffle the range randomly.
remove_ifTo remove the values of the range if a condition is fulfilled.
removeTo remove the values from the range.
shuffleTo shuffle the range randomly with the help of a generator.
swapTo swap the value of two objects.
swap_rangesTo swap the value of two ranges.
transformTo transform all the values in a range.
unique_copyTo copy the unique elements of the range.
uniqueTo identify the unique element of the range.

 

Non-modifying sequence operations:

FUNCTION USES
all_ofTo test a condition to all the elements of the range.
any_ofTo test a condition to some or any of the elements of the range.
adjacent_findTo make a search for finding the equal and adjacent elements in a range.
countTo get the count of a value in the range.
count_ifTo get the count of values that satisfies a condition.
equalTo check if the two ranges have all elements equal.
 find_if To find an element in the range.
find_if_notTo find an element in the range but in the opposite way as the above one.
find_endTo get the last element of the range.
find_first_ofThe find for the element that satisfies a condition and occurs at the first.
 for_eachTo apply an operation to all the elements of the range.
findTo find a value in the range.
is_permutationTo check whether the range in reference is a permutation of some other range.
mismatch

 

To get the value in sequence which is the first mismatch.
none_ofTo check if none of the elements follow the condition or not.
 searchTo search for the subsequence in a range.
search_nTo search the range for the occurrence of an element.

 

Partitions

FUNCTION USES
is_partitionedTo deduce whether the range is partitioned or not.
partitionTo partition the range.
partition_copyTo copy the range after partition.
partition_pointTo return the partition point for a range.
stable_partitionTo partition the range in two stable halves.

 

Sorting

FUNCTIONUSES
is_sortedTo check whether the range is sorted or not.
is_sorted_untilTo check till which element a range is sorted.
nth_elementTo sort the elements in the range.
partial_sort_copyTo copy the elements of the range after sorting it.
partial_sortTo partially sort the elements of the range.
stable_sortTo sort the elements in the range maintaining the relative equivalent order.
sortTo sort all the elements in a range.

 

 

Please follow and like us:
error
Posted in CPP   








Copyright © 2019 CodesJava DMCA.com Protection Status