SetIterator.h 1013 B

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