当前位置: 首页>>代码示例>>C++>>正文


C++ Ordered_list::begin方法代码示例

本文整理汇总了C++中Ordered_list::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Ordered_list::begin方法的具体用法?C++ Ordered_list::begin怎么用?C++ Ordered_list::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ordered_list的用法示例。


在下文中一共展示了Ordered_list::begin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:robkeim,项目名称:random,代码行数:37,代码来源:p2_main.cpp

示例2: print_ptr

void print_ptr(Ordered_list<T>& in_list)
{
	for(typename Ordered_list<T>::Iterator it = in_list.begin(); it != in_list.end(); it++) {
		if(it != in_list.begin())	// output a leading space after the first one
			cout << ' ';
		cout << *(*it);
	}
	cout << endl;
}
开发者ID:robkeim,项目名称:random,代码行数:9,代码来源:d_ol1.cpp

示例3: delete_Collection

// Deletes a specified collection.  An error occurs if a collection with the
// specified name does not exist.
void delete_Collection(Ordered_list<Collection> &catalog)
{
	String name;
	cin >> name;
	
	Ordered_list<Collection>::Iterator it = catalog.begin();
	
	while (it != catalog.end())
	{
		if (it -> get_name() == name)
		{
			it -> clear();
			catalog.erase(it);

			num_Collections--;
			cout << "Collection " << name << " deleted" << endl;
			
			return;
		}
		
		++it;
	}

	throw Error("No collection with that name!");
	
	return;
}
开发者ID:robkeim,项目名称:random,代码行数:29,代码来源:p2_main.cpp

示例4: 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;
}
开发者ID:robkeim,项目名称:random,代码行数:37,代码来源:p2_main.cpp

示例5: 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

示例6: 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;
}
开发者ID:robkeim,项目名称:random,代码行数:21,代码来源:p2_main.cpp

示例7: 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;
}
开发者ID:robkeim,项目名称:random,代码行数:21,代码来源:p2_main.cpp

示例8: print_Collection_using_name

// Prints the contents of a collection with a specified name.  An error
// occurs if a collection of that name does not exist.
void print_Collection_using_name(const Ordered_list<Collection> &catalog)
{
	String name;
	cin >> name;
	
	Ordered_list<Collection>::Iterator it = catalog.begin();
	while (it != catalog.end())
	{
		if (it -> get_name() == name)
		{
			cout << *it;
			return;
		}
		
		++it;
	}
	
	throw Error("No collection with that name!");
	
	return;
}
开发者ID:robkeim,项目名称:random,代码行数:23,代码来源:p2_main.cpp

示例9: clear_Library

// This clears the contents of the current library.  An error occurs if
// there is a collection with one or more members.
void clear_Library(Ordered_list<Record *> &library_by_title, Ordered_list<Record *> &library_by_ID, const Ordered_list<Collection> &catalog)
{
	Ordered_list<Collection>::Iterator it = catalog.begin();
	while (it != catalog.end())
	{
		if (!it -> empty())
		{
			throw Error("Cannot clear all records unless all collections are empty!");
		}
		++it;
	}
	
	empty_record_list(library_by_title);
	// We've already called the destructors for the pointers to records
	//   so now we just need to clear the other list
	library_by_ID.clear();	
	
	num_Records = 0;
	
	cout << "All records deleted" << endl;
	
	return;
}
开发者ID:robkeim,项目名称:random,代码行数:25,代码来源:p2_main.cpp

示例10: add_Collection

// Add collection with a specified name.  An error occurs if the catalog
// already has a collection with the specified name.
void add_Collection(Ordered_list<Collection> &catalog)
{
	String name;
	cin >> name;
	
	Ordered_list<Collection>::Iterator it = catalog.begin();
	while (it != catalog.end())
	{
		if (it -> get_name() == name)
		{
			throw Error("Catalog already has a collection with this name!");
		}
		++it;
	}

	catalog.insert(Collection(name));
	
	num_Collections++;
	
	cout << "Collection " << name << " added" << endl;
	
	return;
}
开发者ID:robkeim,项目名称:random,代码行数:25,代码来源:p2_main.cpp

示例11: 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;
}
开发者ID:robkeim,项目名称:random,代码行数:40,代码来源:p2_main.cpp


注:本文中的Ordered_list::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。