本文整理汇总了C++中array_t::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ array_t::push_back方法的具体用法?C++ array_t::push_back怎么用?C++ array_t::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array_t
的用法示例。
在下文中一共展示了array_t::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_item
void find_item(std::size_t& lenmax, const array_t::value_type& from, const array_t::value_type& to, array_t& path = array_t(), visited_t& visited = visited_t())
{
if (path.size() > lenmax)
return;
path.push_back(from);
if (from->word_id == to->word_id)
{
lenmax = path.size() - 2;
dump(path);
return;
}
visited.insert(std::make_pair(from->word_id, 1));
for (auto& s : from->similar) {
auto hit = visited.find(s->word_id);
if (hit != visited.end() && hit->second > 12535000) {
hit_reached++;
continue;
}
if (hit != visited.end())
hit->second++;
// исключить зацикливание
if (std::find(path.begin(), path.end(), s) != path.end())
continue;
array_t another;
another = path;
find_item(lenmax, s, to, another, visited);
}
}
示例2: is_argument_list
// argument_list = expression { "," expression }.
bool expression_parser::is_argument_list(array_t& expression_stack) {
if (!is_expression(expression_stack))
return false;
std::size_t count = 1;
while (is_token(comma_k)) {
require_expression(expression_stack);
++count;
}
expression_stack.push_back(any_regular_t(double(count)));
expression_stack.push_back(any_regular_t(array_k));
return true;
}
示例3: is_named_argument_list
// named_argument_list = named_argument { "," named_argument }.
bool expression_parser::is_named_argument_list(array_t& expression_stack) {
if (!is_named_argument(expression_stack))
return false;
std::size_t count = 1;
while (is_token(comma_k)) {
if (!is_named_argument(expression_stack))
throw_exception("Named argument required.");
++count;
}
expression_stack.push_back(any_regular_t(double(count)));
expression_stack.push_back(any_regular_t(dictionary_k));
return true;
}
示例4: fseek
/// Write the dictionary one keyword at a time. This version requires on
/// write call on each keyword, which can be time consuming when there are
/// many keywords.
int ibis::dictionary::writeKeys(FILE *fptr, uint32_t nkeys,
array_t<uint64_t> &pos,
array_t<uint32_t> &qos) const {
int ierr = fseek(fptr, 8*(nkeys+1)+4*nkeys, SEEK_CUR);
long int tmp = ftell(fptr);
pos.clear();
qos.clear();
pos.push_back(tmp);
for (uint32_t j = 0; j < raw_.size(); ++ j) {
if (raw_[j] != 0) {
const int len = 1 + std::strlen(raw_[j]);
ierr = fwrite(raw_[j], 1, len, fptr);
LOGGER(ierr != len && ibis::gVerbose > 1)
<< "Warning -- dictionary::writeKeys failed to write key["
<< j << "]; expected fwrite to return " << len
<< ", but got " << ierr;
tmp += len;
qos.push_back(j);
pos.push_back(tmp);
}
}
tmp = 0;
// go back to write the offsets/positions
ierr = fseek(fptr, 24, SEEK_SET);
LOGGER(ierr != 0 && ibis::gVerbose > 1)
<< "Warning -- dictionary::writeKeys failed to seek to offset 24 "
"to write the offsets";
ierr = fwrite(pos.begin(), sizeof(uint64_t), nkeys+1, fptr);
LOGGER(ierr != (int)(nkeys+1) && ibis::gVerbose > 1)
<< "Warning -- dictionary::writeKeys failed to write the offsets, "
"expected fwrite to return " << nkeys+1 << ", but got " << ierr;
tmp -= 7 * (ierr != (int)(nkeys+1));
ierr = fwrite(qos.begin(), sizeof(uint32_t), nkeys, fptr);
LOGGER(ierr != (int)(nkeys) && ibis::gVerbose > 1)
<< "Warning -- dictionary::writeKeys failed to write the keys, "
"expected fwrite to return " << nkeys << ", but got " << ierr;
tmp -= 8 * (ierr != (int)(nkeys));
return tmp;
} // ibis::dictionary::writeKeys
示例5: is_postfix_expression
bool expression_parser::is_postfix_expression(array_t& expression_stack) {
if (!is_primary_expression(expression_stack))
return false;
while (true) {
if (is_token(open_bracket_k)) {
require_expression(expression_stack);
require_token(close_bracket_k);
} else if (is_token(dot_k)) {
any_regular_t result;
require_token(identifier_k, result);
expression_stack.push_back(result);
} else
break;
expression_stack.push_back(any_regular_t(index_k));
}
return true;
}
示例6: is_variable_or_function
// variable_or_function = identifier ["(" [argument_expression_list] ")"].
bool expression_parser::is_variable_or_function(array_t& expression_stack) {
any_regular_t result;
if (!is_token(identifier_k, result))
return false;
if (is_token(open_parenthesis_k)) {
// If there are no parameters then set the parameters to an empty array.
if (!is_argument_expression_list(expression_stack))
expression_stack.push_back(any_regular_t(adobe::array_t()));
require_token(close_parenthesis_k);
expression_stack.push_back(result);
expression_stack.push_back(any_regular_t(function_k));
} else {
expression_stack.push_back(result);
expression_stack.push_back(any_regular_t(variable_k));
}
return true;
}
示例7: is_multiplicative_expression
// multiplicative_expression = unary_expression { ("*" | "/" | "%") unary_expression }.
bool expression_parser::is_multiplicative_expression(array_t& expression_stack) {
if (!is_unary_expression(expression_stack))
return false;
name_t operator_l;
while (is_multiplicative_operator(operator_l)) {
if (!is_unary_expression(expression_stack))
throw_exception("Primary required.");
expression_stack.push_back(any_regular_t(operator_l));
}
return true;
}
示例8: is_equality_expression
// equality_expression = relational_expression { ("==" | "!=") relational_expression }.
bool expression_parser::is_equality_expression(array_t& expression_stack) {
if (!is_relational_expression(expression_stack))
return false;
bool is_equal = false;
while ((is_equal = is_token(equal_k)) || is_token(not_equal_k)) {
if (!is_relational_expression(expression_stack))
throw_exception("Primary required.");
expression_stack.push_back(is_equal ? any_regular_t(equal_k) : any_regular_t(not_equal_k));
}
return true;
}
示例9: is_bitwise_and_expression
// bitwise_and_expression = equality_expression { "&" equality_expression }.
bool expression_parser::is_bitwise_and_expression(array_t& expression_stack) {
if (!is_equality_expression(expression_stack))
return false;
while (is_token(bitwise_and_k)) {
array_t operand2;
if (!is_equality_expression(operand2))
throw_exception("equality_expression required");
push_back(expression_stack, operand2);
expression_stack.push_back(any_regular_t(bitwise_and_k));
}
return true;
}
示例10: is_unary_expression
bool expression_parser::is_unary_expression(array_t& expression_stack) {
if (is_postfix_expression(expression_stack))
return true;
name_t operator_l;
if (is_unary_operator(operator_l)) {
if (!is_unary_expression(expression_stack))
throw_exception("Unary expression required.");
if (operator_l != add_k)
expression_stack.push_back(any_regular_t(operator_l));
return true;
}
return false;
}
示例11: is_named_argument
// named_argument = identifier ":" expression.
bool expression_parser::is_named_argument(array_t& expression_stack) {
/* NOTE (sparent) : This is the one point in the grammar where we need the LL(2) parser. */
name_t ident;
if (!is_identifier(ident))
return false;
if (!is_token(colon_k)) {
putback(); // the identifier
return false;
}
expression_stack.push_back(any_regular_t(ident));
require_expression(expression_stack);
return true;
}
示例12: is_expression
// expression = or_expression ["?" expression ":" expression].
bool expression_parser::is_expression(array_t& expression_stack) {
if (!is_or_expression(expression_stack))
return false;
if (!is_token(question_k))
return true;
array_t operand2;
array_t operand3;
require_expression(operand2);
require_token(colon_k);
require_expression(operand3);
push_back(expression_stack, operand2);
push_back(expression_stack, operand3);
expression_stack.push_back(any_regular_t(ifelse_k));
return true;
}
示例13: is_primary_expression
bool expression_parser::is_primary_expression(array_t& expression_stack) {
any_regular_t result; // empty result used if is_keyword(empty_k)
if (is_name(result) || is_token(number_k, result) || is_boolean(result) ||
is_token(string_k, result) || is_keyword(empty_k)) {
expression_stack.push_back(std::move(result));
return true;
} else if (is_array(expression_stack))
return true;
else if (is_dictionary(expression_stack))
return true;
else if (is_variable_or_function(expression_stack))
return true;
else if (is_token(open_parenthesis_k)) {
require_expression(expression_stack);
require_token(close_parenthesis_k);
return true;
}
return false;
}
示例14: if
/// Find all codes that matches the SQL LIKE pattern.
/// If the pattern is null or empty, matches is not changed.
void ibis::dictionary::patternSearch(const char* pat,
array_t<uint32_t>& matches) const {
if (pat == 0) return;
if (*pat == 0) return;
if (key_.size() == 0) return;
if (! (code_.size() == key_.size() &&
key_.size()+1 == raw_.size())) {
LOGGER(ibis::gVerbose > 0)
<< "Warning -- dictionary::patternSearch(" << pat
<< ") can not proceed because the member variables have "
"inconsistent sizes: raw_.size(" << raw_.size() << ", key_.size("
<< key_.size() << "), and code_.size(" << code_.size() << ')';
return;
}
#if FASTBIT_CASE_SENSITIVE_COMPARE+0 == 0
for (char *ptr = const_cast<char*>(pat); *ptr != 0; ++ ptr) {
*ptr = toupper(*ptr);
}
#endif
// extract longest constant prefix to restrict range
size_t pos;
bool esc = false;
bool meta = false;
std::string prefix;
const size_t len = strlen(pat);
for (pos = 0; pos < len && !meta; ++pos) {
const char c = *(pat + pos);
if (esc) {
prefix.append(1, c);
esc = false;
}
else {
switch (c) {
case STRMATCH_META_ESCAPE:
esc = true;
break;
case STRMATCH_META_CSH_ANY:
case STRMATCH_META_CSH_ONE:
case STRMATCH_META_SQL_ANY:
case STRMATCH_META_SQL_ONE:
meta = true;
break;
default:
prefix.append(1, c);
break;
}
}
}
// if there is no meta char, find the string directly
if (!meta) {
uint32_t code = operator[](prefix.c_str());
if (code < raw_.size()) {
matches.push_back(code);
}
return;
}
// locate prefix to restrict matching range
int32_t min = -1, max = -1;
if (prefix.size() == 0) {
min = 0;
max = key_.size();
}
else if (key_.size() < 16) {
// use linear search
for (uint32_t m = 0; m < key_.size(); ++ m) {
if (min < 0) {
int comp = strncmp(key_[m], prefix.c_str(), prefix.length());
if (comp == 0) {
min = m;
}
else if (comp > 0) {
break;
}
}
else if (max < 0) {
if (strncmp(key_[m], prefix.c_str(), prefix.length()) != 0) {
max = m;
break;
}
}
}
if (min < 0) return;
if (max < 0) max = key_.size();
}
else {
// find lower bound using binary search
int32_t b = 0;
int32_t e = key_.size() - 1;
while (b <= e) {
int32_t m = (b + e) / 2;
if (strncmp(key_[m], prefix.c_str(), prefix.size()) >= 0) {
e = m - 1;
}
else {
b = m + 1;
//.........这里部分代码省略.........
示例15: LOGGER
/// Find all codes that matches the SQL LIKE pattern.
/// If the pattern is null or empty, matches is not changed.
void ibis::dictionary::patternSearch(const char* pat,
array_t<uint32_t>& matches) const {
if (pat == 0) return;
//if (*pat == 0) return;//empty string is allowed
if (key_.size() == 0) return;
if (key_.size() > raw_.size()) {
LOGGER(ibis::gVerbose > 0)
<< "Warning -- dictionary::patternSearch(" << pat
<< ") can not proceed because the member variables have "
"inconsistent sizes: raw_.size(" << raw_.size() << ", key_.size("
<< key_.size() << ')';
return;
}
#if FASTBIT_CASE_SENSITIVE_COMPARE+0 == 0
for (char *ptr = const_cast<char*>(pat); *ptr != 0; ++ ptr) {
*ptr = toupper(*ptr);
}
#endif
// extract longest constant prefix to restrict range
size_t pos;
bool esc = false;
bool meta = false;
std::string prefix;
const size_t len = std::strlen(pat);
for (pos = 0; pos < len && !meta; ++pos) {
const char c = *(pat + pos);
if (esc) {
prefix.append(1, c);
esc = false;
}
else {
switch (c) {
case STRMATCH_META_ESCAPE:
esc = true;
break;
case STRMATCH_META_CSH_ANY:
case STRMATCH_META_CSH_ONE:
case STRMATCH_META_SQL_ANY:
case STRMATCH_META_SQL_ONE:
meta = true;
break;
default:
prefix.append(1, c);
break;
}
}
}
// if there is no meta char, find the string already
if (!meta) {
uint32_t code = operator[](prefix.c_str());
if (code < raw_.size()) {
matches.push_back(code);
}
return;
}
// match values in the range
for (MYMAP::const_iterator j = key_.begin();
j != key_.end(); ++ j) {
if (ibis::util::strMatch(j->first, pat)) {
matches.push_back(j->second);
}
}
#if DEBUG+0 > 2 || _DEBUG+0 > 2
ibis::util::logger lg;
lg() << "DEBUG -- dictionary::patternSearch(" << pat << ") found "
<< matches.size() << " matching value" << (matches.size()>1?"s":"")
<< ":\t";
for (unsigned j = 0; j < matches.size(); ++ j)
lg() << matches[j] << ' ';
#endif
} // ibis::dictionary::patternSearch