TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 98

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 98', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | std cout parking_lot_guard leave car_id n If there are no registered cars or if the car isn t registered sound the alarm std pair iterator iterator p std equal_range cars_- begin cars_- end car_id if cars_- end car_id alarm_ car_id else cars_- erase That s it Of course as we haven t connected any slots to any signals yet there s a bit more to do. Still these classes are remarkably simple for what they re about to do. To make the shared_ptrs for the alarm and the car identifiers behave correctly we implement the default constructor where the signal and the vector are properly allocated. The implicitly created copy constructor the destructor and the assignment operator will all do the right thing thanks to these fine smart pointers . The function connect_to_alarm forwards to call to the contained signal s connect. The function call operator tests the Boolean argument to see whether the car is entering or leaving and makes a call to the corresponding function enter leave. In the function enter the first thing that s done is to search through the vector for the identifier of the car. Finding it would mean that something has gone wrong perhaps someone has stolen a license plate. The search is performed using the algorithm binary_search 3 which expects a sorted sequence we make sure that it always is sorted . If we do find the identifier we immediately sound the alarm which involves invoking the signal. alarm_ car_id We need to dereference alarm_ first because alarm_ is a boost shared_ptr and when invoking it we pass to it the argument that is the car identifier. If we don t find the identifier all is well and we insert the car identifier into cars_ at the correct place. Remember that we need the sequence to be sorted at all times and the best way to ensure that is by inserting elements in a location such that the ordering isn t compromised. Using the algorithm lower_bound gives us this location in the sequence this algorithm also expects a sorted

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.