Thinking in C++ 2nd edition Volume 2 Standard Libraries & Advanced Topics revision 1 phần 6

Một vấn đề mà thường đi kèm trong chương trình là quản lý của các đối số chương trình mà bạn có thể chỉ định trên dòng lệnh. Thông thường, bạn muốn có một thiết lập mặc định mà có thể được thay đổi thông qua dòng lệnh. Các công cụ | Forwarditerator max_element ForwardIterator first Forwarditerator last Forwarditerator max_element Forwarditerator first Forwarditerator last BinaryPredicate binary_pred Returns an iterator pointing to the first occurrence of the largest value in the range there may be multiple occurrences of the largest value . Returns last if the range is empty. The first version performs comparisons with operator and the value r returned is such that r e is false for every element e in the range. The second version compares using binary_pred and the value r returned is such that binary_pred r e is false for every element e in the range. void replace Forwarditerator first Forwarditerator last const T old_value const T new_value void replace_if Forwarditerator first Forwarditerator last Predicate pred const T new_value Outputiterator replace_copy inputiterator first Inputiterator last Outputiterator result const T old_value const T new_value Outputiterator replace_copy_if inputiterator first inputiterator last Outputiterator result Predicate pred const T new_value Each of the replace forms moves through the range first last finding values that match a criterion and replacing them with new_value. Both replace and replace_copy simply look for old_value to replace while replace_if and replace_copy_if look for values that satisfy the predicate pred. The copy versions of the functions do not modify the original range but instead make a copy with the replacements into result incrementing result after each assignment . Example To provide easy viewing of the results this example will manipulate vectors of int. Again not every possible version of each algorithm will be shown some that should be obvious have been omitted . C05 The STL search and replace algorithms include include vector include algorithm include functional using namespace std struct PlusOne bool operator int i int j return j i 1 Chapter 15 Multiple Inheritance 301 class MulMoreThan int .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.