+ check if index is valid in to_string()
+ output feature id
This commit is contained in:
parent
16828ec161
commit
ff66cc1326
1 changed files with 6 additions and 2 deletions
|
@ -254,13 +254,17 @@ public:
|
||||||
std::string to_string() const
|
std::string to_string() const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Feature (" << std::endl;
|
ss << "Feature ( id=" << id_ << std::endl;
|
||||||
context_type::map_type::const_iterator itr = ctx_->mapping_.begin();
|
context_type::map_type::const_iterator itr = ctx_->mapping_.begin();
|
||||||
context_type::map_type::const_iterator end = ctx_->mapping_.end();
|
context_type::map_type::const_iterator end = ctx_->mapping_.end();
|
||||||
for ( ;itr!=end; ++itr)
|
for ( ;itr!=end; ++itr)
|
||||||
|
{
|
||||||
|
std::size_t index = itr->second;
|
||||||
|
if (index < data_.size())
|
||||||
{
|
{
|
||||||
ss << " " << itr->first << ":" << data_[itr->second] << std::endl;
|
ss << " " << itr->first << ":" << data_[itr->second] << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ss << ")" << std::endl;
|
ss << ")" << std::endl;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue