mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Add Values() method for IDWeakMap
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user