本文整理汇总了C++中LinkList::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ LinkList::Count方法的具体用法?C++ LinkList::Count怎么用?C++ LinkList::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkList
的用法示例。
在下文中一共展示了LinkList::Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Display
void Display(LinkList<T> &list)
{
cout << list.Count() << " element(s): ";
for (int i = 1; i <= list.Count(); i++)
{
cout << list.Get(i) << " ";
}
cout << endl;
}
示例2: main
int main()
{
LinkList<int> ll;
cout << "Created a link list..." << endl;
cout << "length = " << ll.Count() << endl;
for (int i = 1; i <= 10; i++)
{
int val = i * 2;
ll.Insert(val, ll.Count() + 1);
cout << val << " inserted. length = " << ll.Count() << endl;
}
Display(ll);
cout << "Reversing ..." << endl;
ll.Reverse();
Display(ll);
cout << "Reversing again ..." << endl;
ll.Reverse();
Display(ll);
int idx = 1;
int val = ll.Get(idx);
cout << "Get(" << idx << ") = " << val << "." << endl;
idx = ll.Locate(val);
cout << "Locate(" << val << ") = " << idx << "." << endl;
if (idx == ll.Locate(val))
{
cout << val << " is at " << idx << "." << endl;
}
idx = 7;
val = ll.Get(idx);
if (idx == ll.Locate(val))
{
cout << val << " is at " << idx << "." << endl;
}
idx = ll.Count();
val = ll.Get(idx);
if (idx == ll.Locate(val))
{
cout << val << " is at " << idx << "." << endl;
}
val = 9999999;
if (-1 == ll.Locate(val))
{
cout << "Unable to locate " << val << "." << endl;
}
cout << "Inserting 3 at 3 ..." << endl;
ll.Insert(3, 3);
Display(ll);
cout << "Deleting 3 ..." << endl;
ll.Delete(3);
Display(ll);
cout << "Inserting 0 at 1 ..." << endl;
ll.Insert(0, 1);
Display(ll);
cout << "Deleting 0 ..." << endl;
ll.Delete(1);
Display(ll);
cout << "Inserting 11 at 12 ..." << endl;
ll.Insert(11, 11);
Display(ll);
cout << "Deleting 11 ..." << endl;
ll.Delete(11);
Display(ll);
try
{
cout << "call LinkList<int> lla = ll ..." << endl;
LinkList<int> lla = ll;
cout << "lla.length = " << lla.Count() << endl;
cout << "call LinkList<int> llb(ll) ..." << endl;
LinkList<int> llb(ll);
cout << "llb.length = " << llb.Count() << endl;
llb.Insert(77, 7);
cout << "llb.length = " << llb.Count() << endl;
cout << "call llb = lla ..." << endl;
llb = lla;
cout << "llb.length = " << llb.Count() << endl;
cout << "lla.length = " << lla.Count() << endl;
cout << "Splitting llb ..." << endl;
llb.Insert(88, 8);
cout << "llb.length = " << llb.Count() << endl;
LinkList<int> llb2 = llb.Split();
Display(llb);
Display(llb2);
cout << "Splitting ll ..." << endl;
LinkList<int> llc = ll.Split();
Display(ll);
Display(llc);
//.........这里部分代码省略.........