C++ Library - <algorithm>


Advertisements


Introduction to algorithm

The algorithm library provides several functions that can be used for a variety of purposes, for instance searching, sorting, counting, manipulating and so on. These functions operate on ranges of elements and the range is defined as [first, last).

Functions from <algorithm>

Below is list of all methods from <algorithm> header.

Member functions

S.N. Method & Description
1 algorithm::adjacent_find()

Finds the first occurrence of two consecutive elements that are identical and returns an iterator pointing to the first element if identical element exists consecutively otherwise returns an iterator pointing to the last element.

2 algorithm::adjacent_find()

Finds the first occurrence of two consecutive elements that are identical and returns an iterator pointing to the first element if identical element exists consecutively otherwise returns an iterator pointing to the last element.

3 algorithm::all_of()

Returns true if predicate returns true for all the elements in the range of first to last.

4 algorithm::any_of()

Returns true if predicate returns true for any of the elements in the range of first to last.

5 algorithm::binary_search()

Tests whether value exists in sorted sequence or not.

6 algorithm::binary_search()

Tests whether value exists in sorted sequence or not.

7 algorithm::copy()

Copies a range of elements to a new location.

8 algorithm::copy_backward()

Copies a range of elements to a new location in backward order.

9 algorithm::copy_if()

Copies a range of elements to a new location if predicate returns true for value.

10 algorithm::copy_n()

Copies first n numbers to a new location.

11 algorithm::count()

Returns the number of occurrences of value in range.

12 algorithm::count_if()

Returns the number of occurrences of value from range that satisfies condition.

13 algorithm::equal()

Tests whether two sets of element are equal or not.

14 algorithm::equal()

Tests whether two sets of element are equal or not.

15 algorithm::equal_range()

Returns a range of element that matches specific key.

16 algorithm::equal_range()

Returns a range of element that matches specific key.

17 algorithm::fill()

Assigns certain value to a range of elements.

18 algorithm::fill_n()

Assigns value to the first n elements of the sequence pointed by first.

19 algorithm::fill_n()

Assigns value to the first n elements of the sequence pointed by first.

20 algorithm::find()

Finds the first occurrence of the element.

21 algorithm::find_end()

Finds the last occurrence of the element.

22 algorithm::find_end()

Finds the last occurrence of the element.

23 algorithm::find_first_of()

Returns an iterator to the first element in the range of (first1,last1) that matches any of the elements in first2,last2.

24 algorithm::find_first_of()

Returns an iterator to the first element in the range of (first1,last1) that matches any of the elements in first2,last2.

25 algorithm::find_if()

Finds the first occurrence of the element that satisfies the condition.

26 algorithm::find_if_not()

Finds the last occurrence of the element that satisfies the condition.

27 algorithm::for_each()

Applies provided function on each element of the range.

28 algorithm::generate()

Assigns the value returned by successive calls to gen to the elements in the range of first to last.

29 algorithm::generate_n()

Assigns the value returned by successive calls to gen to the first n elements of the sequence pointed by the first.

30 algorithm::generate_n()

Assigns the value returned by successive calls to gen to the first n elements of the sequence pointed by the first.

31 algorithm::includes()

Test whether first set is subset of another or not.

32 algorithm::includes()

Test whether first set is subset of another or not.

33 algorithm::inplace_merge()

Merges two sorted sequence in-place.

34 algorithm::inplace_merge()

Merges two sorted sequence in-place.

35 algorithm::is_heap()

Tests whether given sequence is max heap or not.

36 algorithm::is_heap()

Tests whether given sequence is max heap or not.

37 algorithm::is_heap_until()

Finds the first element from the sequence which violates the max heap condition.

38 algorithm::is_heap_until()

Finds the first element from the sequence which violates the max heap condition.

39 algorithm::is_partitioned()

Tests whether range is partitioned or not.

40 algorithm::is_permutation()

Tests whether a sequence is permutation of other or not.

41 algorithm::is_permutation()

Tests whether a sequence is permutation of other or not.

42 algorithm::is_sorted()

Tests whether range is sorted or not.

43 algorithm::is_sorted()

Tests whether range is sorted or not.

44 algorithm::is_sorted_until()

Finds first unsorted element from the sequence.

45 algorithm::is_sorted_until()

Finds first unsorted element from the sequence.

46 algorithm::iter_swap()

Exchange values of objects pointed by two iterators.

47 algorithm::lexicographical_compare()

Tests whether one range is lexicographically less than another or not.

48 algorithm::lexicographical_compare()

Tests whether one range is lexicographically less than another or not.

49 algorithm::lower_bound()

Finds the first element not less than the given value.

50 algorithm::lower_bound()

Finds the first element not less than the given value.



Advertisements