Container-specific algorithm

List and forward_list member function version algorithm:

operating Explanation
lst.merge(lst2) To lst2merge the elements from lst, both must be ordered and the elements will lst2be removed from it.
lst.merge(lst2, comp) As above, the above version uses the <operator, and this version uses the given comparison operation.
lst.remove(val) The call erasedeletes every element equal to the given value (==)
lst.remove_if(pred) Call to erasedelete each element that makes the unary predicate true
lst.reverse() Reverse lstthe order of elements in
lst.sort() Use <sorted elements
lst.sort(comp) Sort elements using the given comparison operation
lst.unique() Call to erasedelete consecutive copies of the same value.
lst.unique(pred) The above version uses the use of ==,这个版本the given binary predicate.
The above operations all returnvoid

 

Parameters of the splice member function version of list and forward_list:

splice This algorithm is unique to the linked list data structure, there is no universal version

lst.splice(args) 或 flst.splice_after(args)
parameter Explanation
(p,lst2) pIs an lstiterator that points to the element in the middle, or an iterator that points to flstthe front. The function moves lst2all elements lstin the position pbefore or  after the flstmiddle . The elements from deletion. The type must be the same and cannot be the same linked list.plst2lst2lst
(p,lst2, p2) As above, it p2is an lst2effective iterator that points to the middle position, moves the p2pointed element into lstmiddle, or moves the  p2following elements into flstmiddle. lst2It can be the same lstor the flstsame linked list.
(p,lst2, b,e) bAnd the legal scope in the erepresentation lst2. lst2Move the elements in the given range from lstor firstto. lst2And lstyou can make the same list, but pcan not point to the element in a given range.


Guess you like

Origin www.cnblogs.com/Real-Ying/p/12741232.html