Summary of C ++ standard library

Source: Internet
Author: User
Tags bitset mathematical functions
Document directory
  • 1. Container
  • 2. Algorithm
  • 3. function object
  • 4. iterator
  • 5. Distributor
  • 6. Numeric Value

 

1. Container 1.1 Sequence
    vector=========================<vector>
list===========================<list>
deque==========================<deque>
1.2 sequence Adapter
    stack:top,push,pop=============<stack>
queue:front,back,push,pop======<queue>
priority_queue:top,push,pop====<queue>
1.3 associate containers
    map============================<map>
multimap=======================<map>
set============================<set>
multiset=======================<set>
1.4 proposed Container
    string=========================<string>
valarray=======================<valarray>
bitset=========================<bitset>
2. algorithm 2.1 Non-modifyed sequence operation
<Algorithm>
For_each () ============================== perform operations on each element in the sequence
Find () ================================== find the first occurrence of a value in the sequence
Find_if () ================================ find the first element that matches a certain predicate in the sequence
Find_first_of () ====================== find the value in another sequence in the sequence
Adjust_find () ============================ find an adjacent pair of Values
Count () ================================== count the number of times a value appears in the sequence
Count_if () ================================ count the number of times a predicate matches in the sequence
Mismatch () =================================find the first element that makes the two sequences different
Equal () ================================== true if the two sequences correspond to the same element
Search () ===================================find a sequence as the first occurrence position of the subsequence
Find_end () =================================find a sequence as the last occurrence position of the subsequence
Search_n () =================================find the nth occurrence position of a sequence as a subsequence
2.2 modification sequence operation
<Algorithm>
Transform () ============================== apply the operation to each element in the sequence
Copy () ============================== copy from the first element of the sequence
Copy_backward () ====================== copy from the last element of the sequence
Swap () ============================== exchange two elements
Iter_swap () ============================= exchange two elements referred to by the iterator
Swap_ranges () ========================== exchange elements in the two sequences
Replace () ================================ replace some elements with a given value
Replace_if () ============================ replace some elements that meet the Predicate
Replace_copy () ====================== replace an element with a given value when replicating a sequence
Replace_copy_if () ================ Replace the element that meets the predicate in the Copy Sequence
Fill () ================================ replace all elements with a given value
Fill_n () ================================ Replace the first n elements with a given value
Generate () ================================ replace all elements with the result of an operation
Generate_n () =========================== Replace the first n elements with the result of an operation
Remove () ===================================delete an element with a given value
Remove_if () ============================ Delete the element that meets the Predicate
Remove_copy () ========================== elements that are specified for deleting a Copy Sequence
Remove_copy_if () ================== Delete the element that meets the predicate in the Copy Sequence
Unique () ============================== Delete adjacent duplicate elements
Unique_copy () =========================== Delete adjacent duplicate elements in the replication Sequence
Reexample () =============================== reverse the order of Elements
Reexample_copy () ========================= reverse the order of elements in the Copy Sequence
Rotate () =
Rotate_copy () =========================== elements that are moved cyclically when the replication sequence is copied
Random_shuffle () ==================== use uniform distribution to move Random Elements
2.3 sequencing
<Algorithm>
Sort () ================================ sort in a good average order
Stable_sort () ========================== sort and maintain the original order of the same element
Partial_sort () ======================== sort the first part of the sequence in order
Partial_sort_copy () ============== sort the first part of the sequence in sequence while copying
Nth_element () ============================ place the nth element in its correct position
Lower_bound () ========================== find the first occurrence of a value
Upper_bound () ===========================find the first
Equal_range () ============================ find a subsequence with a given value
Binary_search () ====================== determine whether the given element exists in the sorted Sequence
Merge () ================================ merge two sorted Sequences
Inplace_merge () ===================== merge the sorted sequences of two successive
Partition () ============================== put all elements that meet a certain predicate in front
Stable_partition () ================ put all elements that satisfy a certain predicate in front and maintain the original order
2.4 Set Algorithms
<Algorithm>
Include () ================================== if one sequence is another subsequence, it is true
Set_union () ============================== construct a sorted Union
Set_intersection () =============== construct an sorted Intersection
Set_difference () ================== construct an ordered sequence that contains elements in the first sequence but not in the second sequence
Set_effecric_difference () ==== construct a sorted sequence, including all the elements that are only in one of the two sequences
2.5 heap operations
<Algorithm>
Make_heap () ============================== use a sequence as a heap at a high speed
Push_heap () ============================ add an element to the heap
Pop_heap () ============================ remove elements from the heap
Sort_heap () ============================= sort the heap
2.6 Max and min
<Algorithm>
Min () ================================ smaller values of the two
Max () =
Min_element () ============================ minimum element in the sequence
Max_element () ============================== maximum element in the sequence
Lexicographic_compare () ======= the first of the two sequences in the lexicographically Ascending Order
2.7
<Algorithm>
Next_permutation () =============== sort by lexicographically
Prev_permutation () =============== sort by the previous lexicographically
2.8 General Numerical Algorithm
<Numeric>
Accumulate () =========================== accumulate the results of computation in a sequence (promotion of vector elements)
Inner_product () ======================= accumulate the results of the computation in the two sequences (Inner Product)
Partial_sum () ========================= generate a sequence (incremental change) by performing operations on the sequence)
Adjacent_difference () =========== generate a sequence by performing operations on the sequence (opposite to partial_sum)
2.9 C-style Algorithm
<Cstdlib>
Qsort () ================================== fast sorting, elements cannot have user-defined structures, copy assignment and destructor
Bsearch () ================================ binary search, elements cannot have user-defined structures, copy assignment and destructor
3. function object 3.1 base class
    template<class Arg, class Res> struct unary_function
template<class Arg, class Arg2, class Res> struct binary_function
3.2 predicates

Returns the bool function object.

<Functional>
Required _to ================================= binary, arg1 = arg2
Not_1__to ============================= binary, arg1! = Arg2
Greater ================================== binary, arg1> arg2
Less ======================== binary, arg1 <arg2
Greater_equal =========================== binary, arg1> = arg2
Less_equal =============================== binary, arg1 <= arg2
Logical_and =============================== binary, arg1 & arg2
Logical_or =============================== binary, arg1 | arg2
Logical_not ================================ Mona ,! ARG
3.3 arithmetic function object
<Functional>
Plus ======================== binary, arg1 + arg2
Minus ====================== binary, arg1-arg2
Multiplies ================================= binary, arg1 * arg2
Divides ================================ binary, arg1/arg2
Modulus ================================ binary, arg1 % arg2
Negate ==================================== Mona,-Arg
3.4 constraint, adapter, and negative
<Functional>
Bind2nd (y)
Binder2nd ============================ use y as the second parameter to call a binary function
Bind1st (X)
Binder1st ============================ use X as the first parameter to call a binary function
Mem_fun ()
Mem_fun_t =
Mem_fun1_t =
Const_mem_fun_t ============= call the 0 RMB const member function through a pointer
Const_mem_fun1_t =========== call the one-dimensional const member function through a pointer
Mem_fun_ref ()
Mem_fun_ref_t =
Mem_fun1_ref_t =============== call the mona1 member function by referencing
Const_mem_fun_ref_t ======= call the 0 RMB const member function through reference
Const_mem_fun1_ref_t ===== call the one-dimensional const member function by referencing
Ptr_fun ()
Pointer_to_unary_function = call the mona1 function pointer
Ptr_fun ()
Pointer_to_binary_function = call a binary function pointer
Not1 ()
Unary_negate ===================== negative unary predicates
Not2 ()
Binary_negate ================= negative binary predicates
4. iterator 4.1 Classification
    Output: *p= , ++
Input: =*p , -> , ++ , == , !=
Forward: *p= , =*p , -> , ++ , == , !=
Bidirectional: *p= , =*p -> , [] , ++ , -- , == , !=
Random: += , -= , *p= , =*p -> , [] , ++ , -- , + , - , == , != , < , > , <= , >=
4.2 plug-in
    template<class Cont> back_insert_iterator<Cont> back_inserter(Cont& c);
template<class Cont> front_insert_iterator<Cont> front_inserter(Cont& c);
template<class Cont, class Out> insert_iterator<Cont> back_inserter(Cont& c, Out p);
4.3 reverse iterator
    reexample_iterator===============rbegin(), rend()
4.4 stream iterator
Ostream_iterator ==================== used to write data to ostream
Istream_iterator ==================== used to read data from istream
Ostreambuf_iterator ============== used to write data to the stream buffer
Istreambuf_iterator ============== used to read data from the stream buffer
5. Distributor
<memory>
template<class T> class std::allocator
6. Limit of 6.1 values
<limits>
numeric_limits<>
<climits>
CHAR_BIT
INT_MAX
...
<cfloat>
DBL_MIN_EXP
FLT_RADIX
LDBL_MAX
...
6.2 standard mathematical functions
<Cmath>
Double ABS (double) =============== absolute value (not in C), same as FABs ()
Double FABS (double) ============= absolute value
Double Ceil (double D) ========== minimum integer not less than D
Double floor (double D) ========== maximum integer not greater than D
Double SQRT (double D) =========== D is at the square root, D must be non-negative
Double POW (double D, double E) = E Power of d
Double POW (double D, int I) === I power of d
Double cos (double) ================ cosine
Double sin (double) =============== sine
Double Tan (double) =============== tangent
Double ACOs (double) ============= arccosine
Double asin (double) ============= arcsin
Double atan (double) ============= arc tangent
Double atan2 (Double X, Double Y) // atan (x/y)
Double sinh (double) ============= hyperbolic sine
Double cosh (double) ============= hyperbolic cosine
Double Tanh (double) ============= hyperbolic tangent
Double exp (double) ============== exponent, with E as the base
Double Log (double D) =========== automatic logarithm (base on E), D must be greater than 0
Double log10 (double D) ========= 10 Base logarithm, D must be greater than 0
Double MODF (double D, double * P) = returns the fractional part of D. The integer part is saved to * P.
Double frexp (double D, int * P) = finds X, Y in [0.5, 1), so that D = x * POW (2, Y ), returns X and saves y to * P.
Double fmod (double D, double m) = floating point remainder, the symbol is the same as d
Double ldexp (double D, int I) = D * POW (2, I)
<Cstdlib>
Int ABS (INT) ============================= absolute value
Long ABS (long) ========================= absolute value (not in C)
Long labs (long) ======================= absolute value
Struct div_t {implementation_defined quot, REM ;}
Struct ldiv_t {implementation_defined quot, REM ;}
Div_t Div (int n, int d) ======= divide N with D and return (quotient, remainder)
Ldiv_t Div (long N, long d) === Division N with D, return (quotient, remainder) (not in C)
Ldiv_t ldiv (long N, long d) === Division N with D, return (quotient, remainder)
6.3 vector Arithmetic
<valarray>
valarray
6.4 plural Arithmetic
<complex>
template<class T> class std::complex;
6.5 General Numerical Algorithm

See 2.8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.