List and forward_list member function version algorithm:
operating | Explanation |
---|---|
lst.merge(lst2) |
To lst2 merge the elements from lst , both must be ordered and the elements will lst2 be 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 erase deletes every element equal to the given value (==) |
lst.remove_if(pred) |
Call to erase delete each element that makes the unary predicate true |
lst.reverse() |
Reverse lst the order of elements in |
lst.sort() |
Use < sorted elements |
lst.sort(comp) |
Sort elements using the given comparison operation |
lst.unique() |
Call to erase delete 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) |
p Is an lst iterator that points to the element in the middle, or an iterator that points to flst the front. The function moves lst2 all elements lst in the position p before or after the flst middle . The elements from deletion. The type must be the same and cannot be the same linked list.p lst2 lst2 lst |
(p,lst2, p2) |
As above, it p2 is an lst2 effective iterator that points to the middle position, moves the p2 pointed element into lst middle, or moves the p2 following elements into flst middle. lst2 It can be the same lst or the flst same linked list. |
(p,lst2, b,e) |
b And the legal scope in the e representation lst2 . lst2 Move the elements in the given range from lst or first to. lst2 And lst you can make the same list, but p can not point to the element in a given range. |