本文整理汇总了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);
}
}
示例2: onParams
void FullbrightMaterialComponent::onParams(const CaffUtil::Param ¶ms)
{
// 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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例7: onParams
void PointLightComponent::onParams(const CaffUtil::Param ¶ms)
{
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);
}
示例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;
};
示例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;
}
示例10: select
std::string select(){
if (++current_ >= methods_.size()) {
current_ = 0;
}
return methods_.at(current_);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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 "";
}
示例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;
}