本文整理汇总了C++中Mapping::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Mapping::at方法的具体用法?C++ Mapping::at怎么用?C++ Mapping::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapping
的用法示例。
在下文中一共展示了Mapping::at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort_as
void Mapping::sort_as(const Mapping & map)
{
object_list_type n;
std::set<Object> t_set(this->_lst.begin(), this->_lst.end());
for(object_list_type::const_iterator i = map._lst.begin(); i != map._lst.end(); ++i)
{
if(t_set.find(*i) != t_set.end())
{
n.push_back(*i);
}
}
std::set<Object> o_set(n.begin(), n.end());
for(object_list_type::const_iterator i = this->_lst.begin(); i != this->_lst.end(); ++i)
{
if(o_set.find(*i) == o_set.end())
{
n.push_back(*i);
}
else
{
// key is also in "map"
Object & tv = this->at(*i);
const Object & ov = map.at(*i);
if(tv.is<Mapping>() && ov.is<Mapping>())
{
Mapping & tm = reinterpret_cast<Mapping &>(tv.get_object());
const Mapping & om = reinterpret_cast<const Mapping &>(ov.get_object());
tm.sort_as(om);
}
}
}
if(this->_lst.size() != n.size())
{
std::cerr << "internal error" << std::endl;
std::cerr << "this->_lst: " << this->_lst.size() << std::endl;
for(object_list_type::const_iterator i = this->_lst.begin(); i != this->_lst.end(); ++i)
{
std::cerr << " " << i->repr() << std::endl;
}
std::cerr << "n: " << n.size() << std::endl;
for(object_list_type::const_iterator i = n.begin(); i != n.end(); ++i)
{
std::cerr << " " << i->repr() << std::endl;
}
std::cout << this->_lst.size() << " " << n.size() << std::endl;
throw InternalError(DEBUG_INFO, "key sorting was not successful");
assert(false);
}
this->_lst = n;
}