From c1ba464daf64d5c03a2fb6db94b20a61db0cf85c Mon Sep 17 00:00:00 2001 From: stmctommyau Date: Sat, 9 Sep 2023 23:15:01 +0800 Subject: [PATCH] some more cleanup --- normal_user.h | 94 --------------------------------------------------- 1 file changed, 94 deletions(-) diff --git a/normal_user.h b/normal_user.h index 283dc7e..501b6cc 100644 --- a/normal_user.h +++ b/normal_user.h @@ -70,100 +70,6 @@ void * show_item(void * ddb,int index){ getchar(); return ddb; } - -//user for showing list result and search result -// void list_page(struct inventory db,struct Map* map,int row,struct inventory (*showitem)(struct inventory,int)){//showitem is a function pointer for showing item,allow customization for better flexibilty -// int choice = -1; -// int page = 0; -// int page_size = PAGE_SIZE; -// int total_pages = ceil((double)row / page_size); -// do{ - -// //options -// Cls(); -// printf("0 exit\n"); -// printf("1 sort name decending\n"); -// printf("2 sort name ascending\n"); -// printf("3 sort price decending\n"); -// printf("4 sort price ascending\n"); -// printf("5 sort brand decending\n"); -// printf("6 sort brand ascending\n"); -// printf("7 sort category decending\n"); -// printf("8 sort category ascending\n"); -// printf("List of items:\n"); - -// //print items -// if(page + 1 >= total_pages){ -// print_page(db, page * page_size, row,map); -// }else{ -// print_page(db, page * page_size, (page + 1) * page_size,map); -// } - -// //page control -// int current_page_size = 8 + page_size; -// if(page + 1 >= total_pages){ -// current_page_size = row - page * page_size+8; -// } -// printf("%d next page\n", current_page_size+1); -// printf("%d previous page\n", current_page_size+2); -// printf("%d set page size\n", current_page_size+3); -// printf("%d/%d/%d(page size/page number/total)\n",page_size, page+1,total_pages); - -// //prompt user to select an item -// bool valid = true; -// do{ -// valid = true; -// printf("Enter your choice: "); -// fflush_stdin(); -// scanf("%d", &choice); -// if(choice <=8 && choice > 0){ -// printf("sorting...\n"); -// map = sortItems(db,choice); -// }else if(choice == current_page_size+1 ){ -// if(page + 1 < total_pages){ -// page++; -// }else{ -// printf("Already at last page\n"); -// valid = false; -// } -// }else if(choice == current_page_size+2){ -// if(page > 0){ -// page--; -// }else{ -// printf("Already at first page\n"); -// valid = false; -// } -// }else if(choice == current_page_size+3){ -// printf("Enter page size: "); -// fflush_stdin(); -// scanf("%d", &page_size); -// total_pages = ceil((double)row / page_size); -// }else if(choice >= 9 && choice <= current_page_size){ -// if(map == NULL){ -// db = (*showitem)(db,choice - 9 + page_size*page); -// }else{ -// db = (*showitem)(db,map[choice - 9 + page_size*page].key); -// } -// }else if(choice != 0){ -// printf("Invalid choice\n"); -// valid = false; -// } -// }while(!valid); - -// }while(choice != 0); -// } -//print the list for the page -// void print_page(struct inventory db, int cur, int end,struct Map* map){ -// for (int i = cur; i < end; i++) -// { -// if(map != NULL){ -// printf("%d item %d: %s\n", i + 9,i, db.row[map[i].key].product); -// } -// else{ -// printf("%d item %d: %s\n", i + 9,i, db.row[i].product); -// } -// } -// } void print_page(void * ddb, int cur, int end,struct Map* map){ struct inventory db = *((struct inventory*)ddb); for (int i = cur; i < end; i++)