Armature::Link &Armature::add_link()
{
- links.push_back(Link(string(), links.size()));
+ links.emplace_back(string(), links.size());
return links.back();
}
const Armature::Link &Armature::get_link(unsigned index) const
{
- for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
- if(i->get_index()==index)
- return *i;
- throw key_error(typeid(list<Link>));
+ for(const Link &l: links)
+ if(l.get_index()==index)
+ return l;
+ throw key_error(index);
}
const Armature::Link &Armature::get_link(const string &name) const
{
- for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
- if(i->get_name()==name)
- return *i;
- throw key_error(typeid(list<Link>));
+ for(const Link &l: links)
+ if(l.get_name()==name)
+ return l;
+ throw key_error(name);
}
unsigned Armature::get_max_link_index() const
{
unsigned max_index = 0;
- for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
- max_index = max(max_index, i->get_index());
+ for(const Link &l: links)
+ max_index = max(max_index, l.get_index());
return max_index;
}