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


C++ deque::at方法代码示例

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


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

示例1: dispatcher_

 result_type
 operator () (lhs_op_rhs const & _top) const
 {
     return dispatcher_(output_.at(_top.lhs_),
                        _top.operator_,
                        output_.at(_top.rhs_));
 }
开发者ID:tomilov,项目名称:insituc,代码行数:7,代码来源:shunting_yard_algorithm.hpp

示例2: arrange_twin

EXPORT void arrange_twin(std::deque<HWND> const& hwnds_, long const& width_, long const& height_){
  if(0 == hwnds_.size()){
    // nop
  }
  else if(1 == hwnds_.size()){
    resize_window(hwnds_.at(0), HWND_NOTOPMOST, SW_SHOWNORMAL, 0, 0, width_, height_);
  }
  else if(2 == hwnds_.size()){
    resize_window(hwnds_.at(0), HWND_NOTOPMOST, SW_SHOWNORMAL, 0, 0, width_ / 2        , height_);
    resize_window(hwnds_.at(1), HWND_NOTOPMOST, SW_SHOWNORMAL, width_ / 2, 0, width_ / 2, height_);
  }
  else{
    long const n = hwnds_.size() - 2;
    long const sub_width = width_ / n;

    resize_window(hwnds_.at(0), HWND_NOTOPMOST, SW_SHOWNORMAL, 0        , 0, width_ / 2, height_ / 4 * 3);
    resize_window(hwnds_.at(1), HWND_NOTOPMOST, SW_SHOWNORMAL, width_ / 2, 0, width_ / 2, height_ / 4 * 3);

    for(unsigned int i = 2; i < hwnds_.size(); i++){
      resize_window(hwnds_.at(i), HWND_NOTOPMOST, SW_SHOWNORMAL,
          (sub_width * (i - 2)),
          (height_ / 4 * 3),
          (sub_width),
          (height_ / 4 * 1));
    }
  }
}
开发者ID:rbtnn,项目名称:cpp-tile,代码行数:27,代码来源:arrange_twin.cpp

示例3: maximumContiguousSum

int maximumContiguousSum(std::deque<int> &numbers) {
  int max = 0;
  std::deque<int>::iterator boundary;
  std::deque<int>::iterator adder;
  while (numbers.size() > 0) {
    for (boundary = numbers.end(); boundary != numbers.begin(); boundary--) {
      int testSum = 0;
      for (adder = numbers.begin(); adder != boundary; adder++) {
        testSum += *adder; 
      }
      if (testSum > max) { max = testSum; }
    }
    for (boundary = numbers.begin(); boundary != numbers.end(); boundary++) {
      int testSum = 0;
      for (adder = boundary; adder != numbers.end(); adder++) {
        testSum += *adder;
      }
      if (testSum > max) { max = testSum; }
    }
    if (!numbers.empty()) { numbers.pop_back(); }
    if (!numbers.empty()) { numbers.pop_front(); }
    if (numbers.size() == 1) {
      if (numbers.at(0) > max) { max = numbers.at(0); }
    }
  }
  return max;
}
开发者ID:loadstar81,项目名称:brainfood,代码行数:27,代码来源:017sumofintegers.cpp

示例4: melkman

//Realiza el algoritmo de Melkman para hallar el convex hull de un poligono simple
// La entrada Q debe ser un poligono simple ordenado 
void melkman(std::list<Point2D> & Q, std::deque<Point2D> & D){
    bool volar_b = false;
    bool volar_t = false;
    unsigned int m = 0;
    unsigned int b = 0;
    unsigned int t = 0;
    std::vector<Point2D> V;
    std::list<Point2D>::iterator p = Q.begin();
    while(p != Q.end()){
        V.push_back(*p);
        p++;
    }
    //Inicializa la deque con los primeros 3 en CCW
    if(right(V[0], V[1], V[2])){
        D.push_front(V[2]);
        D.push_front(V[1]);
        D.push_front(V[0]);
        D.push_front(V[2]);
    } else {
        D.push_front(V[2]);
        D.push_front(V[0]);
        D.push_front(V[1]);
        D.push_front(V[2]);
    }

    unsigned int n = Q.size();
    unsigned int i = 2;
    while((++i) < n){
        m = D.size();
        b = 0;
        t = D.size()-1;
        volar_b = right(V[i], D.at(b), D.at(b+1));
        volar_t = right(D.at(t-1), D.at(t), V[i]);
        
        if(!volar_b && !volar_t) //En el cono interno, no se agrega
            continue;

        while(volar_b){             
            D.pop_front();
            volar_b = right(V[i], D.at(b), D.at(b+1));
        }
        D.push_front(V[i]);//Dentro segun el primer segmento
        
        t = D.size()-1;
        volar_t = right(D.at(t-1), D.at(t), V[i]);
        while(volar_t){
            t--;
            D.pop_back();
            volar_t = right(D.at(t-1), D.at(t), V[i]);
        }
        D.push_back(V[i]); //Dentro segun el ultimo segmento
    }
}
开发者ID:fern17,项目名称:geometriacomputacionalFICH,代码行数:55,代码来源:melkman.cpp

示例5: main

int main(int, char**)
{
    {
        std::deque<int> c = make<std::deque<int> >(10);
        for (int i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (int i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
    {
        const std::deque<int> c = make<std::deque<int> >(10);
        for (int i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (int i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
#if TEST_STD_VER >= 11
    {
        std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
        for (int i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (int i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
    {
        const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
        for (int i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (int i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
#endif

  return 0;
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:43,代码来源:access.pass.cpp

示例6: getSpellTypeFromName

int getSpellTypeFromName(std::string name)
{
	for(int i = 0;i<SpellNames.size();i++)
	{
		if(SpellNames.at(i)==name)
		{
			return i;
		}
	}
	return -1;
}
开发者ID:rianneogi,项目名称:Warlocks,代码行数:11,代码来源:Spell.cpp

示例7: main

int main()
{
    {
        std::deque<int> c = make<std::deque<int> >(10);
        for (unsigned i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (unsigned i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
    {
        const std::deque<int> c = make<std::deque<int> >(10);
        for (unsigned i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (unsigned i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
#if __cplusplus >= 201103L || defined(_LIBCPP_MSVC)
    {
        std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
        for (unsigned i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (unsigned i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
    {
        const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
        for (unsigned i = 0; i < 10; ++i)
            assert(c[i] == i);
        for (unsigned i = 0; i < 10; ++i)
            assert(c.at(i) == i);
        assert(c.front() == 0);
        assert(c.back() == 9);
    }
#endif
}
开发者ID:K-ballo,项目名称:libcxx,代码行数:41,代码来源:access.pass.cpp

示例8: Draw_Buildings

void Draw_Buildings(sf::RenderWindow& window)
{
  for (unsigned i = 0; i < LowerBuildings.size(); ++i)
  {
    Building building = LowerBuildings.at(i);
    sf::RectangleShape buildingShape(sf::Vector2f(ORIGINAL_WIDTH / 10, building.height));
    buildingShape.setFillColor(sf::Color(0, 0, 100));
    buildingShape.setPosition(building.x, building.y);
    buildingShape.setOutlineColor(sf::Color(0, 0, 0));
    buildingShape.setOutlineThickness(1);
    window.draw(buildingShape);
  }
}
开发者ID:jchuong,项目名称:heliassault,代码行数:13,代码来源:game.cpp

示例9: Collision_Check_Buildings

// Checks if buildings collide with player
// TODO: Check for bullets
void Collision_Check_Buildings(void)
{
  // Figure out where the helicopter is
  // Check the buildings within the same x area to save computation
  unsigned x, y;
  Player->Get_Location(&x, &y);
  int right = x + 70;
  int bottom = y + 40;
  if (LowerBuildings.size() < 10) // Not a screen full of buildings, just check all buildings
  {
    for (unsigned i = 0; i < LowerBuildings.size(); ++i)
    {
      if (LowerBuildings.at(i).x < right)
      {
        if (LowerBuildings.at(i).y < bottom)
        {
          // Collision, game over
          assert(false);
        }
      }
    }
  }
  else
  {
    unsigned buildingIndex = std::max(right / (ORIGINAL_WIDTH / 10), (unsigned)0);
    for (unsigned i = 0; i < std::min((unsigned)LowerBuildings.size() - buildingIndex, (unsigned)3); ++i)
    {
      if (LowerBuildings.at(i + buildingIndex).x < right)
      {
        if (LowerBuildings.at(i + buildingIndex).y < bottom)
        {
          // Collision, game over
          assert(false);
        }
      }
    }
  }
}
开发者ID:jchuong,项目名称:heliassault,代码行数:40,代码来源:game.cpp

示例10: Move_Buildings

void Move_Buildings(void)
{
  // We should have created a building before this is called
  // Otherwise, we will null pointer exception, for the cost of not checking if LowerBuildings is not empty
  for (unsigned i = 0; i < LowerBuildings.size(); ++i)
  {
    LowerBuildings.at(i).x -= 1;
  }
  if (LowerBuildings.front().x <= -(int)ORIGINAL_WIDTH / 10)
  {
    LowerBuildings.pop_front();
  }
  Collision_Check_Buildings();
}
开发者ID:jchuong,项目名称:heliassault,代码行数:14,代码来源:game.cpp

示例11: while

inline std::vector<std::string>& CsvFile::GetRow(int row)
{
    std::vector<std::string>& line = mData.at(row);
    while (line.size() < mColCount)
    {
        line.push_back("");
    }
    while (line.size() > mColCount)
    {
        line.pop_back();
    }

    assert(line.size() == mColCount);
    return line;
}
开发者ID:meteor1113,项目名称:library,代码行数:15,代码来源:csvfile.hpp

示例12: RunVisualizationOnly

void RunVisualizationOnly()
{
    if (!viewer->wasStopped())
    {
        viewer->spinOnce(100);
        
        boost::mutex::scoped_lock update_pc_lock(update_pc_model_mutex);
        if (update_pc)
        {
            if (!viewer->updatePointCloud(cloud_ptr, "cloud"))
            {
                viewer->addPointCloud(cloud_ptr, "cloud");
            }
            
            update_pc = false;
        }
        update_pc_lock.unlock();
        
        boost::mutex::scoped_lock update_camera_lock(add_camera_mutex);
        if (update_camera)
        {
            
            if (aggregate_view_frustrums)
            {
                camera_count = 0;
                for (int i=0; i<cam_meshes.size(); i++)
                {
                    viewer->removePolygonMesh(to_string(camera_count));
                    viewer->addPolygonMesh(cam_meshes.at(i).second, to_string(camera_count));
                    camera_count++;
                }
            }
            else
            {
                viewer->removePolygonMesh(to_string(0));
                viewer->addPolygonMesh(cam_meshes.back().second, to_string(0));
            }
    
            update_camera = false;
        }
        
        update_camera_lock.unlock();
        
        viewer->setRepresentationToWireframeForAllActors();
    }
}
开发者ID:HarveyLiuFly,项目名称:shield_slam,代码行数:46,代码来源:Visualizer.cpp

示例13:

cv::Mat CvHelper::convertPoint2fDeque2Mat(std::deque<cv::Point2f> points)
{
	cv::Mat mat;

	if(points.empty())
		return mat;

	mat = cv::Mat(points.size(), 2, CV_32F);

	for (int i = 0; i < points.size(); i++)
	{
		cv::Point2f p = points.at(i);
		mat.at<float>(i,0)= p.x;
		mat.at<float>(i,1)= p.y;
	}
	
	return mat;
}
开发者ID:walachey,项目名称:biotracker_core,代码行数:18,代码来源:CvHelper.cpp

示例14: spnavCallback

void spnavCallback(const geometry_msgs::WrenchStamped::ConstPtr& msg)
{
if(bRunning)
{
  double average_z = 0.0;
  if(num_cache == 0)
    z_cache.pop_front();
  else
    num_cache--;
  z_cache.push_back(msg->wrench.force.z + offset);
  for(unsigned int i = 0; i < z_cache.size(); i++)
    average_z += z_cache.at(i);
  average_z /= z_cache.size();

	geometry_msgs::Twist new_twist;
	/*if(msg->wrench.force.x > 5.0)
	  new_twist.linear.x = 0.01;
	if(msg->wrench.force.x < 5.0)
	  new_twist.linear.x = -0.01;
	if(msg->wrench.force.y > 5.0)
	    new_twist.linear.y = 0.01;
	if(msg->wrench.force.y < 5.0)
	    new_twist.linear.y = -0.01;*/
	if(average_z < -1.0)
	    new_twist.linear.z = -0.01 * average_z;
	else
	  {
	    if(average_z > 1.0)
	      new_twist.linear.z = -0.01 * average_z;
	    else
	      new_twist.linear.z = 0.0;
	  }
	std::cout << "Sending twist of " << new_twist.linear.z << " current force is " << average_z << "\n";
	twist_pub_.publish(new_twist);
}
}
开发者ID:Arbart,项目名称:cob_manipulation,代码行数:36,代码来源:cob_spnav_filter.cpp

示例15:

Spell::Spell(int id,int x,int y,lua_State* L) //custom lua state
{
	SpellType = id;
	sprite = sf::Sprite(SpellTextures.at(id));
	sprite.setPosition(x,y);
	sprite.setScale(0.6f,0.6f);
	cdtext = sf::Text("0",Font,10);
	cdtext.setColor(sf::Color::White);
	cdtext.setPosition(x+4,y+2);
	cdbox = sf::RectangleShape(sf::Vector2f(10,10));
	cdbox.setFillColor(sf::Color::Black);
	cdbox.setPosition(x+3,y+3);

	currCooldown = 0;

	lua_getfield(L,-1,"range");
	Range = lua_tointeger(L,-1);
	//std::cout << "range : " << Range << "\n";
	//lua_pop(L,-1);
	lua_getfield(L,-2,"manaCost");
	ManaCost = lua_tointeger(L,-1);

	lua_getfield(L,-3,"moveCost");
	MoveCost = lua_tointeger(L,-1);
	//std::cout << "movecost : " << MoveCost << "\n";

	lua_getfield(L,-4,"cooldown");
	Cooldown = lua_tointeger(L,-1);
	//std::cout << "cooldown : " << Cooldown << "\n";

	lua_getfield(L,-5,"text");
	Text = lua_tostring(L,-1);

	lua_getfield(L,-6,"name");
	Name = lua_tostring(L,-1);
}
开发者ID:rianneogi,项目名称:Warlocks,代码行数:36,代码来源:Spell.cpp


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