本文整理汇总了C++中HashTable::findMovie方法的典型用法代码示例。如果您正苦于以下问题:C++ HashTable::findMovie方法的具体用法?C++ HashTable::findMovie怎么用?C++ HashTable::findMovie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashTable
的用法示例。
在下文中一共展示了HashTable::findMovie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
HashTable* table = new HashTable(10);
string st,st2;
int sel=0;
while (sel != 5) {
cout<<"======Main Menu======"<<endl;
cout<<"1. Insert movie"<<endl;
cout<<"2. Delete movie"<<endl;
cout<<"3. Find movie"<<endl;
cout<<"4. Print table contents"<<endl;
cout<<"5. Quit"<<endl;
cin>>sel;
if (sel > 5 || sel < 1) {
sel = 5;
}
switch (sel) {
case 1:
cout<<"Enter title:"<<endl;
getline(cin, st);
getline(cin, st);
cout<<"Enter year:"<<endl;
getline(cin, st2);
table->insertMovie(st, stringToInt(st2));
break;
case 2:
cout<<"Enter title:"<<endl;
getline(cin, st);
getline(cin, st);
table->deleteMovie(st);
break;
case 3:
cout<<"Enter title:"<<endl;
getline(cin, st);
getline(cin, st);
table->findMovie(st);
break;
case 4:
table->printTableContents();
break;
default:
cout<<"Goodbye!"<<endl;
break;
}
}
return 0;
}
示例2: main
int main()
{
string command;
HashTable table;
while(command != "5"){
cout << "======Main Menu======" << endl;
cout << "1. Insert Movie" << endl;
cout << "2. Delete Movie" << endl;
cout << "3. Find Movie" << endl;
cout << "4. Print Table Contents" << endl;
cout << "5. Quit" << endl;
getline(cin,command);
if(command == "1"){ //insert
string title;
string year;
cout << "Enter title:" << endl;
getline(cin,title);
cout << "Enter year:" << endl;
getline(cin,year);
table.insertMovie(title, stoi(year));
}
else if(command == "2"){ //delete
string title;
cout << "Enter title:" << endl;
getline(cin,title);
table.deleteMovie(title);
}
else if(command == "3"){ //find
string title;
cout << "Enter title:" << endl;
getline(cin,title);
table.findMovie(title);
}
else if(command == "4"){ //print
table.printTableContents();
}
else if(command=="5"){ //quit
cout << "Goodbye!" << endl;
return EXIT_SUCCESS;
}
}
return 0;
}
示例3: mainFuntions
int mainFuntions(int hashFunc)
{
HashTable h;
h.hashInit();
//h.insertOrderName("", -1);
//h.insertOrderYear("", -1);
string inName, inYear, dName, fName;
int yearInt;
int select = menuSelect();
hashElem *foundNode = NULL;
while (select != 8)
{
switch(select)
{
case 1:
// choose hash function
cout << "Enter title:" << endl;
getline(cin, inName);
cout << "Enter year:" << endl;
getline(cin, inYear);
yearInt = atoi(inYear.c_str());
h.insertMovie(inName, yearInt, hashFunc);
h.insertOrderYear(inName, yearInt);
h.insertOrderName(inName, yearInt);
break;
case 2:
cout << "Enter title:" << endl;
getline(cin, dName);
h.deleteMovie(dName, hashFunc);
break;
case 3:
cout << "Enter title:" << endl;
getline(cin, fName);
foundNode = h.findMovie(fName, hashFunc);
if (foundNode != NULL)
{
cout << foundNode -> title << ":" << foundNode -> year << endl;
}else{
cout << "not found" << endl;
}
break;
case 4:
h.printTableContents();
break;
case 5:
h.printList();
break;
case 6:
h.printListYear();
break;
case 7:
h.colCount(hashFunc);
break;
}
select = menuSelect();
}
cout << "Goodbye!" << endl;
return 1;
}
示例4: main
int main()
{
ifstream in;
in.open("Movies.txt");
string line;
HashTable* hashTable = new HashTable;
while(getline(in, line))
{
int index_comma = line.find(",");
// newItem;
string number = line.substr(0,index_comma);
string parts = line.substr(index_comma+1, line.length()-1);
int index_comma2 = parts.find(",");
string name = parts.substr(0,index_comma2);
string parts2 = parts.substr(index_comma2+1, parts.length()-1);
int index_comma3 = parts2.find(",");
string year = parts2.substr(0, index_comma3);
string parts3 = parts2.substr(index_comma3+1, parts2.length()-1);
int index_comma4 = parts3.find(",");
string quan = parts3.substr(0, index_comma4);
string genre = parts3.substr(index_comma4+1, parts3.length()-1);
int quant = atoi(quan.c_str());
int numb = atoi(number.c_str());
int yr = atoi(year.c_str());
//Movie(name, yr);
hashTable->insertMovie(name, yr, genre, numb, quant);
}
in.close();
string input;
while(input != "7")
{
PrintMenu();
getline(cin, input);
if(input == "1")
{
cout<<"Enter title:"<<endl;
string ins;
string years;
string genres;
string rank;
string quant;
getline(cin, ins);
cout<<"Enter year:"<<endl;
getline(cin, years);
cout<<"Enter genre:"<<endl;
getline(cin, genres);
cout<<"Enter ranking"<<endl;
getline(cin, rank);
cout<<"Enter quantity"<<endl;
getline(cin, quant);
int yrs = atoi(years.c_str());
int ranks = atoi(rank.c_str());
int quants = atoi(quant.c_str());
hashTable->insertMovie(ins, yrs, genres, ranks, quants);
}
else if(input == "2")
{
cout<<"Enter title:"<<endl;
string del;
getline(cin, del);
hashTable->deleteMovie(del);
}
else if(input == "3")
{
cout<<"Enter title:"<<endl;
string toFind;
getline(cin, toFind);
Movie* found = hashTable->findMovie(toFind);
}
else if(input == "4")
{
hashTable->printExistingGenres();
cout<<"Enter genre:"<<endl;
string gen;
getline(cin, gen);
cout<<"======Results======"<<endl;
cout<<endl;
hashTable->printOneGenre(gen);
}
else if(input == "5")
{
hashTable->printTopRanked();
}
else if(input == "6")
{
hashTable->printInventory();
}
else if(input == "7")
{
cout<<"Goodbye!"<<endl;
}
}
//.........这里部分代码省略.........