void PipeLine::cancel_last_packet_reservation(std::shared_ptr<Frame> frame) { auto slack = frame->slack_interval(); auto interval_res = reservations_in_interval(slack); auto result = std::find_if(interval_res.rbegin(), interval_res.rend(), [frame](const pipeline_datatype& pair) -> bool {return frame == pair.second;} ); cancel_reservation(slack.second - 1 - std::distance(interval_res.rbegin(), result)); }
/* Begin to excute function main*/ int main() { int select_opt; FILE *roPtr, *guPtr; if ((roPtr = fopen("room.txt","rb+")) == NULL){ printf("\aRoom file could not be found.\n\n" "Press any to EXIT!"); getch(); } else if ((guPtr = fopen("reserved.txt","rb+")) == NULL){ printf("\aReserve file could not be found.\n\n" "Press any to EXIT!"); getch(); } else { while( (select_opt = main_menu()) != 'X' && (select_opt = main_menu()) != 'x'){ switch(select_opt){ case 'A': case 'a': add_room_info(roPtr); break; case 'B': case 'b': add_reservation(guPtr, roPtr); break; case 'C': case 'c': cancel_reservation(guPtr, roPtr); break; /* case 'D': case 'd': check_in_guest(); break; case 'E': case 'e': check_out_guest(); break; case 'F': case 'f': income_report(); break; */ case 'G': case 'g': report_smoke_nonsmoke(roPtr); break; case 'H': case 'h': reservation_report(guPtr, roPtr); break; default: printf("\a\a"); } select_opt = main_menu(); } } fclose(roPtr); /* ensure that when the program close, */ fclose(guPtr); /* the files close also */ getch(); return 0; }