blob: 63056ae8fee2fda01d4c3db23efe53a546734129 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Map.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Value.h>
namespace JS {
class Set : public Object {
JS_OBJECT(Set, Object);
public:
static Set* create(GlobalObject&);
explicit Set(Object& prototype);
virtual ~Set() override;
// NOTE: Unlike what the spec says, we implement Sets using an underlying map,
// so all the functions below do not directly implement the operations as
// defined by the specification.
void set_clear() { m_values.map_clear(); }
bool set_remove(Value const& value) { return m_values.map_remove(value); }
bool set_has(Value const& key) const { return m_values.map_has(key); }
void set_add(Value const& key) { m_values.map_set(key, js_undefined()); }
size_t set_size() const { return m_values.map_size(); }
auto begin() const { return m_values.begin(); }
auto begin() { return m_values.begin(); }
auto end() const { return m_values.end(); }
private:
virtual void visit_edges(Visitor& visitor) override;
Map m_values;
};
}
|