SetIterator.h 972 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. public:
  14. static SetIterator* create(GlobalObject&, Set& set, Object::PropertyKind iteration_kind);
  15. explicit SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype);
  16. virtual ~SetIterator() override;
  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. virtual void visit_edges(Cell::Visitor&) override;
  23. Set& m_set;
  24. bool m_done { false };
  25. Object::PropertyKind m_iteration_kind;
  26. OrderedHashTable<Value, ValueTraits>::Iterator m_iterator;
  27. };
  28. }