mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
Next commit adds a user of this which doesn't already have the GC_DECLARE_ALLOCATOR() macro available.
40 lines
747 B
C++
40 lines
747 B
C++
/*
|
|
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGC/Cell.h>
|
|
#include <LibGC/CellAllocator.h>
|
|
|
|
namespace GC {
|
|
|
|
template<typename T>
|
|
class HeapVector : public Cell {
|
|
GC_CELL(HeapVector, Cell);
|
|
GC_DECLARE_ALLOCATOR(HeapVector);
|
|
|
|
public:
|
|
HeapVector() = default;
|
|
virtual ~HeapVector() override = default;
|
|
|
|
auto& elements() { return m_elements; }
|
|
auto const& elements() const { return m_elements; }
|
|
|
|
virtual void visit_edges(Visitor& visitor) override
|
|
{
|
|
Base::visit_edges(visitor);
|
|
visitor.visit(m_elements);
|
|
}
|
|
|
|
private:
|
|
Vector<T> m_elements;
|
|
};
|
|
|
|
template<typename T>
|
|
GC_DEFINE_ALLOCATOR(HeapVector<T>);
|
|
|
|
}
|