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

A Complete Guide to Programming in C++ part 81. 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. | EXERCISE Exercise In data communications between two remote computers messages are transmitted via multiple subnets. En route to the target computers so-called routers store these messages in queues before transmitting them towards the target via the next available line. The routers assume responsibility for route discovery generally referring to complex address tables. There are various routing techniques including a simple algorithm that can do without address tables the so-called Hot Potato Algorithm. The router simply tries to dispose of incoming messages as quickly as possible by sending each incoming message to the outgoing line with the shortest queue. Define a container class VecQueue T which is parameterized with a message type T to represent this scenario. The class comprises an array of queues of type vector queue T and a data member used to store the current number of queues in the array. The constructor creates the number of empty queues passed to it as an argument for the array. Additionally you will need to declare the methods size empty push and pop . Overload the size method in two versions If no argument has been passed to the method it returns the current number of messages in all queues. If an argument i of type int has been passed the method returns the current number of messages in the i-th queue. Additionally overload the empty and empty int i methods which return true if all queues or the i-th queue are empty. The push method uses the hot potato algorithm to append a message passed to it at the end of the shortest queue. The pop and pop int i methods are used to simulate the assignment of messages to lines that is retrieval and removal of messages from queues in this exercise. The method pop retrieves the message at the top of a randomly selected queue and deletes it returning the message. The method pop int i retrieves the message at the top of the i-th queue and deletes it returning the message. To test your class declare a container of .

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.