本文整理汇总了C++中Ordered_list::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Ordered_list::find方法的具体用法?C++ Ordered_list::find怎么用?C++ Ordered_list::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ordered_list
的用法示例。
在下文中一共展示了Ordered_list::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_Record_to_Collection
// Add a record to a collection. An error occurs if the collection does not
// exist, an integer cannot be read, an invalid record number is specified,
// or the specified record is already a member of the specified collection.
void add_Record_to_Collection(const Ordered_list<Record *> &library, Ordered_list<Collection> &catalog)
{
String name;
cin >> name;
Collection tmp_Collection(name);
Ordered_list<Collection>::Iterator collection_it = catalog.find(tmp_Collection);
if (collection_it == catalog.end())
{
throw Error("No collection with that name!");
}
int ID = get_int(cin);
Record tmp_Record(ID);
Ordered_list<Record *>::Iterator record_it = library.find(&tmp_Record);
if (record_it == library.end())
{
throw Error("No record with that ID!");
}
collection_it -> add_member(*record_it);
cout << "Member " << ID << " " << (*record_it) -> get_title() << " added" << endl;
return;
}
示例2: remove_Record_from_Collection
// Remove a specified record from a specified collection. Errors occur if
// an integer cannot be read, there is not a record with the specified ID,
// or a collection does not exist with the specified name.
void remove_Record_from_Collection(const Ordered_list<Record *> &library, Ordered_list<Collection> &catalog)
{
String name;
cin >> name;
Ordered_list<Collection>::Iterator it = catalog.begin();
while (it != catalog.end())
{
if (it -> get_name() == name)
{
int ID = get_int(cin);
Record tmp_Record(ID);
Ordered_list<Record *>::Iterator record_it = library.find(&tmp_Record);
if (record_it == library.end())
{
throw Error("No record with that ID!");
}
it -> remove_member(*record_it);
cout << "Member " << ID << " " << (*record_it) -> get_title() << " deleted" << endl;
return;
}
++it;
}
throw Error("No collection with that name!");
return;
}
示例3: delete_Record
// Remove a record from the library. An error occurs if a record with the
// specified title does not exist, or if the specified record is a member of
// one or more collections.
void delete_Record(Ordered_list<Record *> &library_by_title, Ordered_list<Record *> &library_by_ID, const Ordered_list<Collection> &catalog)
{
String title = get_title();
Record tmp_Record(title);
Ordered_list<Record *>::Iterator record_it = library_by_title.find(&tmp_Record);
if (record_it == library_by_title.end())
{
throw Error("No record with that title!");
}
Record * record = *record_it;
Ordered_list<Collection>::Iterator collection_it = catalog.begin();
while (collection_it != catalog.end())
{
if (collection_it -> is_member_present(record))
{
throw Error("Cannot delete a record that is a member of a collection!");
}
++collection_it;
}
library_by_title.erase(record_it);
record_it = library_by_ID.find(record);
library_by_ID.erase(record_it);
num_Records--;
cout << "Record " << record -> get_ID() << " " << record -> get_title() << " deleted" << endl;
delete record;
return;
}
示例4: find_Record_using_ID
// Find a record with a speified ID, and print the information about it.
// An error occurs if an integer cannot be read, or a record with the
// specified ID does not exist.
void find_Record_using_ID(const Ordered_list<Record *> &library)
{
int ID = get_int(cin);
Record tmp_Record(ID);
Ordered_list<Record *>::Iterator it = library.find(&tmp_Record);
if (it == library.end())
{
throw Error("No record with that ID!");
}
cout << **it;
return;
}
示例5: find_Record_using_title
// Find a record with a specified title and print the information about it.
// An error occurs if a record with that name does not exist.
void find_Record_using_title(const Ordered_list<Record *> &library)
{
String title = get_title();
Record tmp_Record(title);
Ordered_list<Record *>::Iterator it = library.find(&tmp_Record);
if (it != library.end())
{
cout << **it;
}
else
{
throw Error("No record with that title!");
}
return;
}
示例6: modify_Record_rating
// Change the rating of a record. Errors occur if an integer cannot be read,
// a record with the specified ID does not exist, or the value of the new
// rating is not in the valid rating range.
void modify_Record_rating(Ordered_list<Record *> &library)
{
int ID = get_int(cin);
Record tmp_Record(ID);
Ordered_list<Record *>::Iterator it = library.find(&tmp_Record);
if (it == library.end())
{
throw Error("No record with that ID!");
}
int rating = get_int(cin);
(*it) -> set_rating(rating);
cout << "Rating for record " << ID << " changed to " << rating << endl;
return;
}
示例7: add_Record
// Add a record to the library. An error occurs if the library already has
// a record with the specified name.
void add_Record(Ordered_list<Record *> &library_by_title, Ordered_list<Record *> &library_by_ID)
{
String medium;
cin >> medium;
String title = get_title();
Record tmp_Record(title);
if (library_by_title.find(&tmp_Record) != library_by_title.end())
{
throw Error("Library already has a record with this title!");
}
Record * record = new Record(medium, title);
library_by_title.insert(record);
library_by_ID.insert(record);
num_Records++;
cout << "Record " << record -> get_ID() << " added" << endl;
return;
}