mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
LibJS: Implement Set.prototype.union
This commit is contained in:
parent
8e1df36588
commit
fee65f6453
6 changed files with 76 additions and 0 deletions
|
@ -23,6 +23,18 @@ void Set::initialize(Realm& realm)
|
|||
m_values = Map::create(realm);
|
||||
}
|
||||
|
||||
NonnullGCPtr<Set> Set::copy() const
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
// FIXME: This is very inefficient, but there's no better way to do this at the moment, as the underlying Map
|
||||
// implementation of m_values uses a non-copyable RedBlackTree.
|
||||
auto* result = Set::create(realm);
|
||||
for (auto const& entry : *this)
|
||||
result->set_add(entry.key);
|
||||
return *result;
|
||||
}
|
||||
|
||||
void Set::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue