本文整理汇总了C++中Pos::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Pos::isValid方法的具体用法?C++ Pos::isValid怎么用?C++ Pos::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pos
的用法示例。
在下文中一共展示了Pos::isValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
int solve(){
memset(tick, 0x1f, sizeof(tick));
Pos start = findCh('S');
Pos target = findCh('T');
//start.display("S");
//start.display("T");
queue<Pos> Q;
Q.push(start);
tick[start.x][start.y][start.color][start.dir] = 0;
while (Q.size()){
Pos s = Q.front(); Q.pop();
//s.display("Pop");
for (int i = 0; i < 3; i++){
Pos t = s.action(i);
if (!t.isValid()) continue;
if (tick[t.x][t.y][t.color][t.dir] != INF) continue;
if (grid[t.x][t.y] == '#') continue;
tick[t.x][t.y][t.color][t.dir] = tick[s.x][s.y][s.color][s.dir] + 1;
Q.push(t);
//s.display(" Push");
}
}
int best = INF;
for (int i = 0; i < 4; i++){
target.dir = i;
best = min(best, tick[target.x][target.y][target.color][target.dir]);
}
return best;
}
示例2: parseImpl
bool ParserCreateQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
ParserKeyword s_create("CREATE");
ParserKeyword s_temporary("TEMPORARY");
ParserKeyword s_attach("ATTACH");
ParserKeyword s_table("TABLE");
ParserKeyword s_database("DATABASE");
ParserKeyword s_if_not_exists("IF NOT EXISTS");
ParserKeyword s_as("AS");
ParserKeyword s_view("VIEW");
ParserKeyword s_materialized("MATERIALIZED");
ParserKeyword s_populate("POPULATE");
ParserToken s_dot(TokenType::Dot);
ParserToken s_lparen(TokenType::OpeningRoundBracket);
ParserToken s_rparen(TokenType::ClosingRoundBracket);
ParserStorage storage_p;
ParserIdentifier name_p;
ParserColumnsOrIndicesDeclarationList columns_or_indices_p;
ParserSelectWithUnionQuery select_p;
ASTPtr database;
ASTPtr table;
ASTPtr columns_list;
ASTPtr to_database;
ASTPtr to_table;
ASTPtr storage;
ASTPtr as_database;
ASTPtr as_table;
ASTPtr select;
String cluster_str;
bool attach = false;
bool if_not_exists = false;
bool is_view = false;
bool is_materialized_view = false;
bool is_populate = false;
bool is_temporary = false;
if (!s_create.ignore(pos, expected))
{
if (s_attach.ignore(pos, expected))
attach = true;
else
return false;
}
if (s_temporary.ignore(pos, expected))
{
is_temporary = true;
}
if (s_table.ignore(pos, expected))
{
if (s_if_not_exists.ignore(pos, expected))
if_not_exists = true;
if (!name_p.parse(pos, table, expected))
return false;
if (s_dot.ignore(pos, expected))
{
database = table;
if (!name_p.parse(pos, table, expected))
return false;
}
if (ParserKeyword{"ON"}.ignore(pos, expected))
{
if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
return false;
}
// Shortcut for ATTACH a previously detached table
if (attach && (!pos.isValid() || pos.get().type == TokenType::Semicolon))
{
auto query = std::make_shared<ASTCreateQuery>();
node = query;
query->attach = attach;
query->if_not_exists = if_not_exists;
query->cluster = cluster_str;
getIdentifierName(database, query->database);
getIdentifierName(table, query->table);
return true;
}
/// List of columns.
if (s_lparen.ignore(pos, expected))
{
if (!columns_or_indices_p.parse(pos, columns_list, expected))
return false;
if (!s_rparen.ignore(pos, expected))
return false;
if (!storage_p.parse(pos, storage, expected) && !is_temporary)
return false;
}
else
//.........这里部分代码省略.........