TAILIEUCHUNG - thinking in c 2nd ed volume 2 rev 20 - phần 6

Tôi đã chỉ trầy xước bề mặt với thực hành được nêu trong chương này. Kết hợp chặt chẽ những gì bạn có thể vào thói quen hàng ngày của bạn, mà còn kiểm tra các quy trình của bạn liên tục và tự hỏi mình làm thế nào bạn có thể thực hiện nhiệm vụ tốt hơn. | 261z516 Because of the genericity of the STL the concept of removal is a bit constrained. Since elements can only be removed via iterators and iterators can point to arrays vectors lists and so on it is not safe or reasonable to actually try to destroy the elements that are being removed and to change the size of the input range first last . An array for example cannot have its size changed. So instead what the STL remove functions do is rearrange the sequence so that the removed elements are at the end of the sequence and the un-removed elements are at the beginning of the sequence in the same order that they were before minus the removed elements that is this is a stable operation . Then the function will return an iterator to the new last element of the sequence which is the end of the sequence without the removed elements and the beginning of the sequence of the removed elements. In other words if new_last is the iterator that is returned from the remove function first new_last is the sequence without any of the removed elements and new_last last is the sequence of removed elements. If you are simply using your sequence including the removed elements with more STL algorithms you can just use new_last as the new past-the-end iterator. However if you re using a resizable container c not an array and you actually want to eliminate the removed elements from the container you can use erase to do so for example Comment remove value You can also use the resize member function that belongs to all standard sequences more on this in the next chapter . C mment The return value of remove is the new_last iterator so erase deletes all the removed elements from c. The iterators in new_last last are dereferenceable but the element values are unspecified and should not be used. ForwardIterator remove ForwardIterator first ForwardIterator last const T value ForwardIterator remove_if ForwardIterator first ForwardIterator last Predicate pred .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.