本文整理汇总了C++中svector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ svector::begin方法的具体用法?C++ svector::begin怎么用?C++ svector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类svector
的用法示例。
在下文中一共展示了svector::begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersect
void intersect(const svector<F,V>& y, Op& op) const {
// can't do bounded search with std::map, otherwise we would do double binary search
// these thresholds have not been well optimized
if (m.size() < 0.1*y.size()) {
for (const_iterator xit=m.begin(); xit != m.end(); ++xit) {
const_iterator yit = y.find(xit->first);
if (yit != y.end())
op(xit->first, xit->second, yit->second);
}
} else if (0.1*m.size() > y.size()) {
for (const_iterator yit=y.begin(); yit != y.end(); ++yit) {
const_iterator xit = m.find(yit->first);
if (xit != m.end())
op(yit->first, xit->second, yit->second);
}
} else {
const_iterator xit = m.begin();
const_iterator yit = y.begin();
while (xit != m.end() && yit != y.end()) {
if (xit->first > yit->first) {
++yit;
} else if (xit->first < yit->first) {
++xit;
} else {
op(xit->first, xit->second, yit->second);
++xit; ++yit;
}
}
}
}
示例2: execute
virtual void execute(cmd_context & ctx) {
ctx.regular_stream() << "\"";
if (m_cmds.empty()) {
vector<named_cmd> cmds;
cmd_context::cmd_iterator it = ctx.begin_cmds();
cmd_context::cmd_iterator end = ctx.end_cmds();
for (; it != end; ++it) {
cmds.push_back(named_cmd((*it).m_key, (*it).m_value));
}
// named_cmd_lt is not a total order for commands, but this is irrelevant for Linux x Windows behavior
std::sort(cmds.begin(), cmds.end(), named_cmd_lt());
vector<named_cmd>::const_iterator it2 = cmds.begin();
vector<named_cmd>::const_iterator end2 = cmds.end();
for (; it2 != end2; ++it2) {
display_cmd(ctx, it2->first, it2->second);
}
}
else {
svector<symbol>::const_iterator it = m_cmds.begin();
svector<symbol>::const_iterator end = m_cmds.end();
for (; it != end; ++it) {
cmd * c = ctx.find_cmd(*it);
SASSERT(c);
display_cmd(ctx, *it, c);
}
}
ctx.regular_stream() << "\"\n";
}
示例3: display
void display(std::ostream & out, symbol const & k) const {
svector<params::entry>::const_iterator it = m_entries.begin();
svector<params::entry>::const_iterator end = m_entries.end();
for (; it != end; ++it) {
if (it->first != k)
continue;
switch (it->second.m_kind) {
case CPK_BOOL:
out << (it->second.m_bool_value?"true":"false");
return;
case CPK_UINT:
out << it->second.m_uint_value;
return;
case CPK_DOUBLE:
out << it->second.m_double_value;
return;
case CPK_NUMERAL:
out << *(it->second.m_rat_value);
return;
case CPK_SYMBOL:
out << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);
return;
case CPK_STRING:
out << it->second.m_str_value;
return;
default:
out << "internal";
return;
}
}
out << "default";
}
示例4: switch
void display_smt2(std::ostream & out, char const* module, param_descrs& descrs) const {
svector<params::entry>::const_iterator it = m_entries.begin();
svector<params::entry>::const_iterator end = m_entries.end();
for (; it != end; ++it) {
if (!descrs.contains(it->first)) continue;
out << "(set-option :";
out << module << ".";
out << it->first;
switch (it->second.m_kind) {
case CPK_BOOL:
out << " " << (it->second.m_bool_value?"true":"false");
break;
case CPK_UINT:
out << " " <<it->second.m_uint_value;
break;
case CPK_DOUBLE:
out << " " << it->second.m_double_value;
break;
case CPK_NUMERAL:
out << " " << *(it->second.m_rat_value);
break;
case CPK_SYMBOL:
out << " " << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);
break;
case CPK_STRING:
out << " " << it->second.m_str_value;
break;
default:
UNREACHABLE();
break;
}
out << ")\n";
}
}
示例5: refill_buffer
void refill_buffer(unsigned start) {
unsigned should_read = m_data_size-start;
m_stm.read(m_data.begin()+start, should_read);
unsigned actually_read = static_cast<unsigned>(m_stm.gcount());
SASSERT(should_read==actually_read || m_stm.eof());
if(m_stm.eof()) {
m_eof_behind_buffer = true;
resize_data(start+actually_read);
}
}
示例6: validate
void validate(param_descrs const & p) const {
svector<params::entry>::const_iterator it = m_entries.begin();
svector<params::entry>::const_iterator end = m_entries.end();
for (; it != end; ++it) {
param_kind expected = p.get_kind(it->first);
if (expected == CPK_INVALID)
throw default_exception("unknown parameter '%s'", it->first.str().c_str());
if (it->second.m_kind != expected)
throw default_exception("parameter kind mismatch '%s'", it->first.str().c_str());
}
}
示例7: SASSERT
/**
\brief Retrieve next line from the stream.
This operation invalidates the line previously retrieved.
This operatio can be called only if we are not at the end of file.
User is free to modify the content of the returned array until the terminating NULL character.
*/
char * get_line() {
SASSERT(!m_eof);
unsigned start = m_next_index;
unsigned curr = start;
for(;;) {
SASSERT(curr<=m_data_size);
SASSERT(m_data[m_data_size]==s_delimiter);
{
const char * data_ptr = m_data.begin();
const char * ptr = data_ptr+curr;
while(*ptr!=s_delimiter) {
ptr++;
}
curr = static_cast<unsigned>(ptr-data_ptr);
}
SASSERT(m_data[curr]==s_delimiter);
if(curr<m_data_size || m_eof_behind_buffer) {
if(curr==m_data_size) {
SASSERT(m_eof_behind_buffer);
m_eof = true;
}
m_data[curr] = 0; //put in string terminator
m_next_index = curr+1;
return m_data.begin()+start;
}
if(start!=0) {
unsigned len = curr-start;
if(len) {
memmove(m_data.begin(), m_data.begin()+start, len);
}
start = 0;
curr = len;
}
if(m_data_size-curr<s_expansion_step) {
resize_data(m_data_size+s_expansion_step);
}
refill_buffer(curr);
}
}
示例8: implode
// concat array of string into one string
std::string implode(const char delimiter, const svector<std::string>& elements)
{
if (elements.empty())
{
return "";
}
std::string res;
svector<string>::const_iterator it = elements.begin();
res = *it;
it++;
for(; it != elements.end(); it++)
{
res += delimiter;
res += *it;
}
return res;
}
示例9: validate
void validate(param_descrs const & p) {
svector<params::entry>::iterator it = m_entries.begin();
svector<params::entry>::iterator end = m_entries.end();
symbol suffix, prefix;
for (; it != end; ++it) {
param_kind expected = p.get_kind_in_module(it->first);
if (expected == CPK_INVALID) {
std::stringstream strm;
strm << "unknown parameter '" << it->first.str() << "'\n";
strm << "Legal parameters are:\n";
p.display(strm, 2, false, false);
throw default_exception(strm.str());
}
if (it->second.m_kind != expected &&
!(it->second.m_kind == CPK_UINT && expected == CPK_NUMERAL)) {
std::stringstream strm;
strm << "Parameter " << it->first.str() << " was given argument of type ";
strm << it->second.m_kind << ", expected " << expected;
throw default_exception(strm.str());
}
}
}