本文整理汇总了C++中Queue::RemoveItemAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Queue::RemoveItemAt方法的具体用法?C++ Queue::RemoveItemAt怎么用?C++ Queue::RemoveItemAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::RemoveItemAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// This program exercises the Queue class.
int main(void)
{
CompleteSetupSystem css; // needed for string-count stats
#ifdef TEST_SWAP_METHOD
while(1)
{
char qs1[512]; printf("Enter q1: "); fflush(stdout); if (fgets(qs1, sizeof(qs1), stdin) == NULL) qs1[0] = '\0';
char qs2[512]; printf("Enter q2: "); fflush(stdout); if (fgets(qs2, sizeof(qs2), stdin) == NULL) qs2[0] = '\0';
Queue<int> q1, q2;
StringTokenizer t1(qs1), t2(qs2);
const char * s;
while((s = t1()) != NULL) q1.AddTail(atoi(s));
while((s = t2()) != NULL) q2.AddTail(atoi(s));
printf("T1Before="); PrintToStream(q1);
printf("T2Before="); PrintToStream(q2);
q1.SwapContents(q2);
printf("T1After="); PrintToStream(q1);
printf("T2After="); PrintToStream(q2);
}
#endif
#ifdef MUSCLE_USE_CPLUSPLUS11
{
Queue<int> q {1,2,3,4,5};
if (q.GetNumItems() != 5) {printf("Oh no, initialize list constructor didn't work!\n"); exit(10);}
q = {6,7,8,9,10,11};
if (q.GetNumItems() != 6) {printf("Oh no, initialize list assignment operator didn't work!\n"); exit(10);}
}
#endif
// Test muscleSwap()
{
Queue<String> q1, q2;
q1.AddTail("q1");
q2.AddTail("q2");
muscleSwap(q1, q2);
if ((q1.GetNumItems() != 1)||(q2.GetNumItems() != 1)||(q1[0] != "q2")||(q2[0] != "q1"))
{
printf("Oh no, muscleSwap is broken for Message objects!\n");
exit(10);
}
printf("muscleSwap() worked!\n");
}
const int testSize = 15;
Queue<int> q;
int vars[] = {5,6,7,8,9,10,11,12,13,14,15};
printf("ADDTAIL TEST\n");
{
for (int i=0; i<testSize; i++)
{
TEST(q.AddTail(i));
printf("len=" UINT32_FORMAT_SPEC"/" UINT32_FORMAT_SPEC"\n", q.GetNumItems(), q.GetNumAllocatedItemSlots());
}
}
printf("AddTail array\n");
q.AddTailMulti(vars, ARRAYITEMS(vars));
PrintToStream(q);
printf("AddHead array\n");
q.AddHeadMulti(vars, ARRAYITEMS(vars));
PrintToStream(q);
printf("REPLACEITEMAT TEST\n");
{
for (int i=0; i<testSize; i++)
{
TEST(q.ReplaceItemAt(i, i+10));
PrintToStream(q);
}
}
printf("INSERTITEMAT TEST\n");
{
for (int i=0; i<testSize; i++)
{
TEST(q.InsertItemAt(i,i));
PrintToStream(q);
}
}
printf("REMOVEITEMAT TEST\n");
{
for (int i=0; i<testSize; i++)
{
TEST(q.RemoveItemAt(i));
PrintToStream(q);
}
}
// Check that C++11's move semantics aren't stealing values they shouldn't
{
Queue<String> q;
//.........这里部分代码省略.........