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


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

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


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

示例1: SetupColumns

void Dlg_AchievementsReporter::SetupColumns()
{
	//	Remove all columns,
	while (ListView_DeleteColumn(m_hList, 0)) {}

	//	Remove all data.
	ListView_DeleteAllItems(m_hList);
	auto limit{ static_cast<int>(col_num) };
	for (auto i = 0; i < limit; i++)
	{

		auto sStr{ std::string{col_names.at(to_unsigned(i))} }; // you can't do it directly

		// would be easier with delegates...
		// Probably should be made in to a class from repetition
		LV_COLUMN col
		{
			LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT,
			LVCFMT_LEFT | LVCFMT_FIXED_WIDTH,
			col_sizes.at(to_unsigned(i)),
			sStr.data(),
			255,
			i
		};

		if (i == limit - 1)	//If the last element: fill to the end
			col.fmt |= LVCFMT_FILL;

		ListView_InsertColumn(m_hList, i, &col);
	}
}
开发者ID:SyrianBallaS,项目名称:RASuite,代码行数:31,代码来源:RA_Dlg_AchievementsReporter.cpp

示例2: onParams

void FullbrightMaterialComponent::onParams(const CaffUtil::Param &params)
{
	// RGB
	{
		const std::array<float, 4> rgba = params["rgba"].asFloat4({m_rgba.r, m_rgba.g, m_rgba.b, m_rgba.a});
		
		enum { R = 0, G, B, A, };
		
		m_rgba.r = rgba.at(R);
		m_rgba.g = rgba.at(G);
		m_rgba.b = rgba.at(B);
		m_rgba.a = rgba.at(A);
	}
	
	// Lookup textureName.
	{
		m_textureName = params["diffuse_map"].asStdString();
	}
	
	// Texture scale
	{
		const std::array<float, 2> uvScale = params["diffuse_map_scale"].asFloat2({m_diffuseScale.x, m_diffuseScale.y});
		
		enum { U = 0, V };
		m_diffuseScale.u = uvScale.at(U);
		m_diffuseScale.v = uvScale.at(V);
	}
}
开发者ID:PhilCK,项目名称:vortex,代码行数:28,代码来源:MaterialComponent.cpp

示例3:

const std::list<sf::Vector2i> King::getValidMoves(const std::array<std::array<std::shared_ptr<Figure>, 8>, 8> &board)
{
	std::list<sf::Vector2i> movements;

#pragma region 1 to all directions

	for(int x = this->m_Position.x -1; x <= this->m_Position.x +1; ++x)
	{
		for(int y = this->m_Position.y -1; y <= this->m_Position.y +1; ++y)
		{
			if(x >= 0 && x < 8 && y >= 0 && y < 8 && (x != 0 || y != 0) )
			{
				if(board.at(x).at(y) != NULL)	// other figure at position
				{
					if(board.at(x).at(y)->isPlayerOne() == this->m_PlayerOne)		// figure of same color -> not a valid move
						continue;
				}
				// different players or no other figure on the field
				movements.push_back(sf::Vector2i(x, y) );
			}
		}
	}
#pragma endregion

	// to do
#pragma region Rochade
	// to do
#pragma endregion

	return movements;
}
开发者ID:Greek6,项目名称:Chess,代码行数:31,代码来源:King.cpp

示例4: validate_lines_information

bool fileinformation::validate_lines_information(std::string& line) {
	std::smatch  matches; 
	bool output = false;
	std::size_t index;
	static bool recursivecomment = false;

	for(index = 0; index < regularexpression.size(); ++index) {
		regularexpression[index].second = std::regex_search(line, matches, regularexpression[index].first);
		/*
		{
				output = true;
				if(index != 2){
					break;
				}
		}
		*/
	}

	recursivecomment = (regularexpression.at(2).second) && !(regularexpression.at(3).second);


	for(index = 0; index < regularexpression.size(); ++index) {
		regularexpression[index].second = false;
	}



	return output;
}
开发者ID:mantosh4u,项目名称:mkrdscpp,代码行数:29,代码来源:filescan.cpp

示例5:

std::array<float, 3> Param::asFloat3(const std::array<float, 3> &defaultData) const
{
    std::array<float, 4> resultArr = asFloat4({{defaultData.at(0), defaultData.at(1), defaultData.at(2), 0.f}});
    std::array<float, 3> returnArr {{ resultArr.at(0), resultArr.at(1), resultArr.at(2) }};

    return returnArr;
}
开发者ID:PhilCK,项目名称:vortex,代码行数:7,代码来源:Param.cpp

示例6: GetPayloadLenght

	 	inline uint32_t GetPayloadLenght(std::array<char, 4>& x)
	 	{
	 		Int32U conv;
	 		conv.c[0] = x.at(0);
	 		conv.c[1] = x.at(1);
	 		conv.c[2] = x.at(2);
	 		conv.c[3] = x.at(3);
	 		return conv.dw;
	 	}
开发者ID:alex529,项目名称:ipcCom,代码行数:9,代码来源:1442249516$EchoServer.cpp

示例7: onParams

void PointLightComponent::onParams(const CaffUtil::Param &params)
{
	const std::array<float, 3> color = params["color"].asFloat3({m_color.x, m_color.y, m_color.z});

	enum { X = 0, Y, Z };
	m_color = CaffMath::Vector3Init(color.at(X), color.at(Y), color.at(Z));

	m_intensity = params["intensity"].asFloat(m_intensity);
	m_radius	= params["radius"].asFloat(m_radius);
}
开发者ID:PhilCK,项目名称:vortex,代码行数:10,代码来源:LightComponent.cpp

示例8: collatz

uint16_t collatz(uint32_t n) {
	uint16_t count = 1;
	while (n != 1) {
		if (n < 1000000 && dm.at(n-1) != 0) {
			return count + dm.at(n-1);
		}
		++count;
		if (n % 2 == 0) {
			n /= 2;
		} else {
			n = 3 * n + 1;
		}
	}
	return count;
};
开发者ID:Ignition,项目名称:Project-Euler,代码行数:15,代码来源:project-euler-014.cpp

示例9: beatableMove

bool Bishop::beatableMove(const sf::Vector2i position, const std::array<std::array<std::shared_ptr<Figure>, 8>, 8> &board)
{
	int rel_x = this->m_Position.x - position.x, rel_y = this->m_Position.y - position.y;

	if( (rel_x != rel_y) && (rel_x != -1*rel_y) )
		return false;

	int relative_movement_x = -1, relative_movement_y = -1;

	if(rel_x < 0)
		relative_movement_x = 1;
	
	if(rel_y < 0)
		relative_movement_y = 1;


	int new_X = this->m_Position.x, new_Y = this->m_Position.y;

	for(int i = relative_movement_x; i != -rel_x; i += relative_movement_x)
	{
		new_X += relative_movement_x;
		new_Y += relative_movement_y;

		if(board.at(new_X).at(new_Y) != NULL)
			return false;
	}
	return true;
}
开发者ID:Greek6,项目名称:Chess,代码行数:28,代码来源:Bishop.cpp

示例10: select

    std::string select(){

        if (++current_ >= methods_.size()) {
            current_ = 0;
        }
        return methods_.at(current_);
    }
开发者ID:michiroooo,项目名称:cppcv,代码行数:7,代码来源:main.cpp

示例11: drawHorizontalSegment

void SingleDigit::drawHorizontalSegment(QPainter &painter, const QPointF& startPoint, bool filled,
                          QBrush &brush)
{
    const std::array<QPointF, 7>baseSegment{
        QPointF(0,0),
        QPointF(3,-3),
        QPointF(23,-3),
        QPointF(26,0),
        QPointF(23,3),
        QPointF(3,3),
        QPointF(0,0)
    };

    QPainterPath segmentPath;

    segmentPath.moveTo(baseSegment.at(0)+startPoint);

    for(auto & point : baseSegment)
        segmentPath.lineTo(point*m_scale + startPoint);

    if(filled)
        painter.fillPath(segmentPath,brush);
    else
        painter.drawPath(segmentPath);
}
开发者ID:DawidPi,项目名称:MKD51-Simulator,代码行数:25,代码来源:singledigit.cpp

示例12: to_num

///
/// Конвертирование текстового ИД константы в ее значение в коде.
/// \return значение константы или -1, если ничего не было найдено
///
int to_num(IdType type, const std::string &str)
{
	if (type < TEXT_ID_COUNT)
	{
		return text_id_list.at(type).to_num(str);
	}
	return -1;
}
开发者ID:Stribog1,项目名称:Bylins,代码行数:12,代码来源:parse.cpp

示例13: handleCollision

void Boss::handleCollision(std::array<bool, CollisionSide::SOLID_TOTAL> detections_){
	if(detections_.at(CollisionSide::SOLID_TOP)){ 
		this->vy = 0.0;
	}
	if(detections_.at(CollisionSide::SOLID_BOTTOM)){		
			this->nextY -= fmod(this->nextY, 64.0) - 16.0;
			this->vy = 0.0;
	}
	if(detections_.at(CollisionSide::SOLID_LEFT)){
		this->nextX = this->x;
		this->vx = 0.0;
	}
	if(detections_.at(CollisionSide::SOLID_RIGHT)){
		this->nextX = this->x;
		this->vx = -0.001;
	}
}
开发者ID:CaioIcy,项目名称:Dauphine,代码行数:17,代码来源:Boss.cpp

示例14: to_str

///
/// Конвертирование значения константы в ее текстовый ИД.
/// \return текстовый ИД константы или пустая строка, если ничего не было найдено
///
std::string to_str(IdType type, int num)
{
	if (type < TEXT_ID_COUNT)
	{
		return text_id_list.at(type).to_str(num);
	}
	return "";
}
开发者ID:Stribog1,项目名称:Bylins,代码行数:12,代码来源:parse.cpp

示例15: print_ar1

void print_ar1(std::array<int, size> ar)
{
  for (int i = 0; i < sizey; i++) {
    for (int j = 0; j < sizex; j++) {
      std::cout << ar.at(i * sizey + j) << " ";
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
}
开发者ID:ban-masa,项目名称:hopfieldnetwork,代码行数:10,代码来源:main.cpp


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