本文整理汇总了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_));
}
示例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));
}
}
}
示例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;
}
示例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
}
}
示例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;
}
示例6: getSpellTypeFromName
int getSpellTypeFromName(std::string name)
{
for(int i = 0;i<SpellNames.size();i++)
{
if(SpellNames.at(i)==name)
{
return i;
}
}
return -1;
}
示例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
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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);
}