mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add bytes() method to FixedArray.
This commit is contained in:
parent
d4fe63d2ce
commit
8e7dfebf11
Notes:
sideshowbarker
2024-07-19 03:35:14 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/8e7dfebf118 Pull-request: https://github.com/SerenityOS/serenity/pull/3166 Reviewed-by: https://github.com/nico
1 changed files with 8 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Span.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace AK {
|
||||
|
@ -33,7 +34,7 @@ namespace AK {
|
|||
template<typename T>
|
||||
class FixedArray {
|
||||
public:
|
||||
FixedArray() {}
|
||||
FixedArray() { }
|
||||
explicit FixedArray(size_t size)
|
||||
: m_size(size)
|
||||
{
|
||||
|
@ -86,6 +87,9 @@ public:
|
|||
return m_elements;
|
||||
}
|
||||
|
||||
Bytes bytes() { return { data(), size() }; }
|
||||
ReadonlyBytes bytes() const { return { data(), size() }; }
|
||||
|
||||
T& operator[](size_t index)
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
|
@ -138,6 +142,9 @@ public:
|
|||
ConstIterator begin() const { return ConstIterator(*this, 0); }
|
||||
ConstIterator end() const { return ConstIterator(*this, size()); }
|
||||
|
||||
operator Bytes() { return bytes(); }
|
||||
operator ReadonlyBytes() const { return bytes(); }
|
||||
|
||||
private:
|
||||
size_t m_size { 0 };
|
||||
T* m_elements { nullptr };
|
||||
|
|
Loading…
Reference in a new issue