Add Values() method for IDWeakMap
This commit is contained in:
parent
5e62b5975b
commit
28d1fb8cad
2 changed files with 11 additions and 0 deletions
|
@ -47,6 +47,14 @@ std::vector<int32_t> IDWeakMap::Keys() const {
|
|||
return keys;
|
||||
}
|
||||
|
||||
std::vector<v8::Local<v8::Object>> IDWeakMap::Values(v8::Isolate* isolate) {
|
||||
std::vector<v8::Local<v8::Object>> keys;
|
||||
keys.reserve(map_.size());
|
||||
for (const auto& iter : map_)
|
||||
keys.emplace_back(v8::Local<v8::Object>::New(isolate, *iter.second));
|
||||
return keys;
|
||||
}
|
||||
|
||||
void IDWeakMap::Remove(int32_t id) {
|
||||
auto iter = map_.find(id);
|
||||
if (iter == map_.end())
|
||||
|
|
|
@ -31,6 +31,9 @@ class IDWeakMap {
|
|||
// Returns IDs of all available objects.
|
||||
std::vector<int32_t> Keys() const;
|
||||
|
||||
// Returns all objects.
|
||||
std::vector<v8::Local<v8::Object>> Values(v8::Isolate* isolate);
|
||||
|
||||
// Remove object with |id| in the WeakMap.
|
||||
void Remove(int32_t key);
|
||||
|
||||
|
|
Loading…
Reference in a new issue