本文整理汇总了C++中Ordered_list::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Ordered_list::size方法的具体用法?C++ Ordered_list::size怎么用?C++ Ordered_list::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ordered_list
的用法示例。
在下文中一共展示了Ordered_list::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_All
// Save the current state of the program to a specified output file. An
// error occurs if the specified file cannot be opened for writing.
void save_All(const Ordered_list<Record *> &library, const Ordered_list<Collection> &catalog)
{
String filename;
cin >> filename;
ofstream os(filename.c_str());
if (!os)
{
throw Error("Could not open file!");
}
os << library.size() << endl;
Ordered_list<Record *>::Iterator record_it = library.begin();
while (record_it != library.end())
{
(*record_it) -> save(os);
++record_it;
}
os << catalog.size() << endl;
Ordered_list<Collection>::Iterator collection_it = catalog.begin();
while (collection_it != catalog.end())
{
collection_it -> save(os);
++collection_it;
}
os.close();
cout << "Data saved" << endl;
return;
}
示例2: print
void print(const char* label, const Ordered_list<T, OF>& in_list)
{
cout << label << " has " << in_list.size() << " items:";
for(typename Ordered_list<T, OF>::Iterator it = in_list.begin(); it != in_list.end(); it++) {
cout << ' ' << *it;
}
cout << endl;
}
开发者ID:sushaoxiang911,项目名称:ObjectOrientedProgramming,代码行数:8,代码来源:Ordered_list_String_exception_safety_demo.cpp
示例3:
Error_code binary_2(const Ordered_list &the_list, const Key &target,
int &position)
{
Record data;
int bottom = 0, top = the_list.size()-1;
while(bottom<=top){
position = (bottom+top)/2;
the_list.retrieve(position,data);
if(data==target) return success;
if(data<target) bottom=position+1;
else top = position-1;
}
return not_present;
}
示例4: print_Catalog
// Prints the contents of the current catalog.
void print_Catalog(const Ordered_list<Collection> &catalog)
{
int num_collections = catalog.size();
if (!num_collections)
{
cout << "Catalog is empty" << endl;
return;
}
cout << "Catalog contains " << num_collections << " collections:" << endl;
Ordered_list<Collection>::Iterator it = catalog.begin();
while (it != catalog.end())
{
cout << *it;
++it;
}
return;
}
示例5: print_Library
// Prints the contents of the currently library.
void print_Library(const Ordered_list<Record *> &library)
{
int num_records = library.size();
if (!num_records)
{
cout << "Library is empty" << endl;
return;
}
cout << "Library contains " << num_records << " records:" << endl;
Ordered_list<Record *>::Iterator it = library.begin();
while (it != library.end())
{
cout << **it;
++it;
}
return;
}