本文整理汇总了C++中Chain::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ Chain::Find方法的具体用法?C++ Chain::Find怎么用?C++ Chain::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chain
的用法示例。
在下文中一共展示了Chain::Find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
Chain<int> chain;
// test size
cout << "Initial size of chain = "
<< chain.Length() << endl;
// test empty
if (chain.IsEmpty()) cout << "chain is empty" << endl;
else cout << "chain is not empty" << endl;
// test insert
chain.Insert(0, 2);
chain.Insert(1, 6);
chain.Insert(0, 1);
chain.Insert(2, 4);
chain.Insert(3, 5);
chain.Insert(2, 3);
cout << "Inserted 6 integers, list chain should be 1 2 3 4 5 6" << endl;
cout << "Size of chain = " << chain.Length() << endl;
if (chain.IsEmpty()) cout << "chain is empty" << endl;
else cout << "chain is not empty" << endl;
chain.Output();
int x = -1,y = -1,z = -1;
// test find and search
bool exist = chain.Find(5,x);
int index = chain.Search(6);
// test delete
chain.Delelte(0,x);
chain.Delelte(3,y);
chain.Delelte(7,z);
cout << "Size of chain = " << chain.Length() << endl;
if (chain.IsEmpty()) cout << "chain is empty" << endl;
else cout << "chain is not empty" << endl;
chain.Output();
return 0;
}
示例2: main
void main(void)
{
try {
Chain<int> L;
cout << "Length = " << L.Length() << endl;
cout << "IsEmpty = " << L.IsEmpty() << endl;
L.Insert(0,2).Insert(1,6);
cout << "List is " << L << endl;
cout << "IsEmpty = " << L.IsEmpty() << endl;
int z;
L.Find(1,z);
cout << "First element is " << z << endl;
cout << "Length = " << L.Length() << endl;
L.Delete(1,z);
cout << "Deleted element is " << z << endl;
cout << "List is " << L << endl;
}
catch (...) {
cerr << "An exception has occurred" << endl;
}
}