/*Inserts copurchases into hash*/ void addToHash(HashRef h, long bookId, ListRef * customers, int custNum, BookRef list){ moveFirst(customers[custNum]); //add cust previous books to hash of current book while(!offEnd(customers[custNum])){ long current = getCurrent(customers[custNum]); if(getId(list)!= current){ //don't add itself to book list insertionSort(getBookList(list), current); } if(atLast(customers[custNum])) break; moveNext(customers[custNum]); } }
//------------------------------------------------------------------------------ QSopherimModuleInfo getModuleInfo(QString fileName) { QSopherimModuleInfo list; list.moduleName = getParamModule(fileName, "ModuleName"); list.moduleShortName = getParamModule(fileName, "ModuleShortName"); // list.append(getParamModule(fileName, "ModuleLanguage")); list.bookValue = getParamModule(fileName, "BooksValue").toInt(); list.modulePath = getParamModule(fileName, "PathToModule"); list.moduleType = getParamModule(fileName, "TypeModule"); list.bookList = getBookList(fileName); list.numberOfChaptersInBook = getNumberOfChaptersInBook(fileName); // myDebug() << list.numberOfChaptersInBook.size(); // myDebug() << list.bookList.size(); // list.append(getParamModule(fileName, "ModuleShortName")); return list; }
/*Gets best recommendation then prints it*/ void printRecommendation(HashRef h, long bookId, ListRef* customers, int custNum){ moveFirst(customers[custNum]); int max=0; long maxId=0; if(getElement(h,bookId)==NULL){ printf("No recommendations for book: %lu\n", bookId); return; } ListRef l = getBookList(getElement(h,bookId)); moveFirst(l); while(!offEnd(l)){ if(getCount(l) >=max && !customerCompare(getCurrent(l), customers, custNum)){ max = getCount(l); maxId=getCurrent(l); } if(atLast(l)) break; moveNext(l); } if(maxId!=0) printf("Recommendation for book %lu is : %lu\n",bookId,maxId); else printf("No recommendations for book: %lu\n", bookId); }