/src/serenity/Userland/Libraries/LibJS/Runtime/SetIterator.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/HashTable.h> |
10 | | #include <LibJS/Runtime/Object.h> |
11 | | #include <LibJS/Runtime/Set.h> |
12 | | |
13 | | namespace JS { |
14 | | |
15 | | class SetIterator final : public Object { |
16 | | JS_OBJECT(SetIterator, Object); |
17 | | JS_DECLARE_ALLOCATOR(SetIterator); |
18 | | |
19 | | public: |
20 | | static NonnullGCPtr<SetIterator> create(Realm&, Set& set, Object::PropertyKind iteration_kind); |
21 | | |
22 | | virtual ~SetIterator() override = default; |
23 | | |
24 | 0 | Set& set() const { return m_set; } |
25 | 0 | bool done() const { return m_done; } |
26 | 0 | Object::PropertyKind iteration_kind() const { return m_iteration_kind; } |
27 | | |
28 | | private: |
29 | | friend class SetIteratorPrototype; |
30 | | |
31 | | explicit SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype); |
32 | | |
33 | | virtual void visit_edges(Cell::Visitor&) override; |
34 | | |
35 | | NonnullGCPtr<Set> m_set; |
36 | | bool m_done { false }; |
37 | | Object::PropertyKind m_iteration_kind; |
38 | | Map::ConstIterator m_iterator; |
39 | | }; |
40 | | |
41 | | } |