mirror of
https://github.com/RGBCube/serenity
synced 2025-05-17 09:45:06 +00:00

This will allow us to use these traits for other hash-based containers (like Map). This commit also adds a special case for negative zero values, because while the equality check used same_value_zero which is negative/positive zero insensitive, the hash was not.
34 lines
829 B
C++
34 lines
829 B
C++
/*
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashTable.h>
|
|
#include <LibJS/Runtime/GlobalObject.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;
|
|
|
|
HashTable<Value, ValueTraits> const& values() const { return m_values; };
|
|
HashTable<Value, ValueTraits>& values() { return m_values; };
|
|
|
|
private:
|
|
virtual void visit_edges(Visitor& visitor) override;
|
|
|
|
HashTable<Value, ValueTraits> m_values; // FIXME: Replace with a HashTable that maintains a linked list of insertion order for correct iteration order
|
|
};
|
|
|
|
}
|