feat(util/name_set): add to_name_set auxiliary function

This commit is contained in:
Leonardo de Moura 2015-07-27 11:32:10 -07:00
parent 6de86ff749
commit 4131bb3dec
2 changed files with 9 additions and 0 deletions

View file

@ -18,6 +18,13 @@ name mk_unique(name_set const & s, name const & suggestion) {
} }
} }
name_set to_name_set(buffer<name> const & ns) {
name_set r;
for (name const & n : ns)
r.insert(n);
return r;
}
DECL_UDATA(name_set) DECL_UDATA(name_set)
static int mk_name_set(lua_State * L) { static int mk_name_set(lua_State * L) {
name_set r; name_set r;

View file

@ -13,6 +13,8 @@ typedef rb_tree<name, name_quick_cmp> name_set;
/** \brief Make a name that does not occur in \c s, based on the given suggestion. */ /** \brief Make a name that does not occur in \c s, based on the given suggestion. */
name mk_unique(name_set const & s, name const & suggestion); name mk_unique(name_set const & s, name const & suggestion);
name_set to_name_set(buffer<name> const & ns);
UDATA_DEFS_CORE(name_set) UDATA_DEFS_CORE(name_set)
void open_name_set(lua_State * L); void open_name_set(lua_State * L);
} }