TAILIEUCHUNG - A Complete Guide to Programming in C++ part 79

A Complete Guide to Programming in C++ part 79. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | INSERTING IN SEQUENCES 759 Insertion Methods The following methods are defined in the container classes vector deque and list push_back insert at end insert insert after a given position. Additionally the following method is available in the list and deque classes push_front insert at beginning. This method is not defined in the vector class. The insert method is overloaded in various versions allowing you to insert a single object multiple copies of an object or object copies from another container. Given two containers v and w the following Example inserts the objects from container v in front of all the other objects in w. A container can of course be assigned to another container of the same type. The assignment operator is overloaded for containers to allow this operation. Runtime Behavior The push_back and push_front methods are preferable on account of their constant runtime. Insertion of one object with the insert method also has a constant runtime in the list class. However this is linear in the vector and deque classes that is the time increases proportionally to the number of objects in the container. This dissimilar runtime behavior for methods can be ascribed to the implementation of various container classes. Normally containers of the list type are represented by double linked lists in which each element possesses a pointer to the preceding and following element. This allows for extremely quick inserting at a given position. The container classes vector and deque are represented as arrays. Inserting in the middle means shifting the objects in the container to make place for the new object. Therefore the runtime will increase proportionally with the number of objects the container holds. Insertion in Adapter Classes There is only one insertion method for adapter classes push . In stacks and queues push appends an object with a constant runtime. Insertion of objects into priority queues depends on the priority of the .

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.