Added conversion from ObjRange to std::vector and std::set

This commit is contained in:
Clifford Wolf 2014-07-27 10:41:06 +02:00
parent 1c8fdaeef8
commit d088854b47
1 changed files with 15 additions and 0 deletions

View File

@ -268,6 +268,21 @@ namespace RTLIL
ObjRange(decltype(list_p) list_p, int *refcount_p) : list_p(list_p), refcount_p(refcount_p) { }
RTLIL::ObjIterator<T> begin() { return RTLIL::ObjIterator<T>(list_p, refcount_p); }
RTLIL::ObjIterator<T> end() { return RTLIL::ObjIterator<T>(); }
operator std::set<T>() const {
std::set<T> result;
for (auto &it : *list_p)
result.insert(it.second);
return result;
}
operator std::vector<T>() const {
std::vector<T> result;
result.reserve(list_p->size());
for (auto &it : *list_p)
result.push_back(it.second);
return result;
}
};
};