本文整理汇总了C++中List::AddHead方法的典型用法代码示例。如果您正苦于以下问题:C++ List::AddHead方法的具体用法?C++ List::AddHead怎么用?C++ List::AddHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List::AddHead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
List L;
L.AddHead(1);
L.AddTail(2);
L.AddHead(3);
L.AddTail(4);
L.AddHead(5);
L.Print();
L.Insert();
L.Print();
L.Print(2);
L.Print(8);
List T;
T = L;
T.Print();
List Sum = -L + T;
Sum.Print();
int a[10] = { 8, 6, 7, 4 };
Sum.AddTailRange(a, 10);
Sum.Print();
cout << boolalpha << Sum.Contains(70) << endl;
cout << Sum << endl;
Sum[2].data = 500;
cout << Sum << endl;
cout << Sum.GetElementAt(5)->data << endl;
List Sum2 = Sum;
cout << boolalpha << Sum2.Equals(Sum) << endl;
Sum[1].data = 500;
cout << boolalpha << Sum2.Equals(Sum) << endl;
cout << "Index of 3 is: " << Sum.IndexOf(3) << endl;
cout << "Last index of 3 is: " << Sum.LastIndexOf(3) << endl;
Sum.InsertRange(a, 5, 1);
cout << Sum << endl;
Sum.Remove(5);
Sum.RemoveAll(500);
Sum.RemoveAll(0);
cout << Sum << endl;
cout << Sum.GetLength() << endl;
Sum.Revers();
cout << Sum << endl;
int * b = Sum.ToArray();
for (int i = 0; i < Sum.GetLength(); i++)
cout << b[i] << " ";
cout << endl;
delete[] b;
Sum.Sort();
cout << Sum << endl;
}
示例2: PushFront
void PushFront(int value)
{
list.AddHead(value,rand() % 10);
count++;
}