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


C++ ArrayQueue::remove方法代码示例

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


在下文中一共展示了ArrayQueue::remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testAddRemove

//Add and remove some items, making sure they come back in the
// correct order
void testAddRemove(ArrayQueue<int>& testQueue){
  testQueue.add(5);
  testQueue.add(10);
  testQueue.add(4);
  if(testQueue.getNumItems() == 3){
    std::cout << "SUCCESS: 3 items added" << std::endl;
  } else {
    std::cout << "ERROR: Added 3 items, but getNumItems says " << testQueue.getNumItems() << std::endl;
    return;
  }
  int x = testQueue.remove();
  int y = testQueue.remove();
  int z = testQueue.remove();
  if(x != 5 || y != 10 || z != 4){
    std::cout << "ERROR: Expected 5, 10, 4, but got " << x <<", " << y << ", " << "z" << std::endl;
  } else {
    std::cout << "SUCCESS: 3 added items came back out in the correct order" << std::endl;
  }
}
开发者ID:richarkc,项目名称:03_Queue_Lab,代码行数:21,代码来源:main.cpp

示例2: testAroundTheHorn

//Test to see if your queue still works if we do add, remove, add, remove
// many times
void testAroundTheHorn(ArrayQueue<int>& testQueue){
  for(int i=0;i<1000;i++){
    testQueue.add(i);
    int t = testQueue.remove();
    if(t != i){
      std::cout << "ERROR: Added " << i << " but got back " << t << std::endl;
      return;
    }
  }
  std::cout << "SUCCESS: Added and removed 1000 items successfully" << std::endl;
}
开发者ID:richarkc,项目名称:03_Queue_Lab,代码行数:13,代码来源:main.cpp

示例3: testRemoveException

//Test to make sure you are throwing an exception if remove is
// called improperly
void testRemoveException(ArrayQueue<int>& testQueue){
  try {
    int t = testQueue.remove();
  } catch (std::string s) {
    std::cout << "SUCCESS: Caught exception: " << s << std::endl;
    return;
  } catch (...) {
    std::cout << "ERROR: Caught an exception, but it wasn't a string type" << std::endl;
    return;
  }

  std::cout << "ERROR: Tried to remove from an empty queue, but did not get an exception" << std::endl;
}
开发者ID:richarkc,项目名称:03_Queue_Lab,代码行数:15,代码来源:main.cpp

示例4: testAroundTheHorn

//Test to see if your queue still works if we do add, remove, add, remove
// many times
void testAroundTheHorn(ArrayQueue<int>& testQueue){
	//std::cout << "IM reall HERE" << std::endl;
	for (int i = 0; i<1000; i++){
		testQueue.add(i);
		int t = testQueue.remove();
		//std::cout << "IM HERE"<<t<<"!!" << std::endl;
		//breaks when trying to access i or t
		if (t != i){
			std::cout << "ERROR: Added " << i << " but got back " << t << std::endl;
			return;
		}
	}
	std::cout << "SUCCESS: Added and removed 1000 items successfully" << std::endl;
}
开发者ID:SiegerJman,项目名称:03_Queue_Lab,代码行数:16,代码来源:main.cpp

示例5: testGrow

//Test to see if your queue can grow to handle lots of items
void testGrow(ArrayQueue<int>& testQueue){
  for(int i=0;i<1000;i++){
    testQueue.add(i);
  }

  if(testQueue.getNumItems() != 1000){
    std::cout << "ERROR: Should have 1000 items in queue, but only found " << testQueue.getNumItems() << std::endl;
    return;
  }

  for(int i=0;i<1000;i++){
    int t = testQueue.remove();
    if(t != i){
      std::cout << "ERROR: Added " << i << " but got back " << t << std::endl;
      return;
    }
  }
  std::cout << "SUCCESS: Added 1000 items, then removed 1000" << std::endl;
}
开发者ID:richarkc,项目名称:03_Queue_Lab,代码行数:20,代码来源:main.cpp


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