some more cleanup

This commit is contained in:
stmctommyau 2023-09-09 23:15:01 +08:00
parent e5e6ffe5a8
commit c1ba464daf
No known key found for this signature in database
GPG Key ID: 87B1991E1277F054

View File

@ -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++)