summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-08-14 12:16:17 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-15 21:21:18 +0200
commit36080c596430983a13f5e01408e34a9b52b78a0a (patch)
treee342be79f5d25956dc1517f36cbf990c9145a236 /AK
parent78849bbb48120651103fef0882ace6dc38c5c9c8 (diff)
downloadserenity-36080c596430983a13f5e01408e34a9b52b78a0a.zip
AK: Add fill() method to Span.
Diffstat (limited to 'AK')
-rw-r--r--AK/Span.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/AK/Span.h b/AK/Span.h
index ccee6c9ba0..31fb59e6b4 100644
--- a/AK/Span.h
+++ b/AK/Span.h
@@ -176,6 +176,13 @@ public:
__builtin_memmove(other.data(), data(), sizeof(T) * min(size(), other.size()));
}
+ ALWAYS_INLINE void fill(const T& value)
+ {
+ for (size_t idx = 0; idx < size(); ++idx) {
+ data()[idx] = value;
+ }
+ }
+
ALWAYS_INLINE const T& at(size_t index) const
{
ASSERT(index < this->m_size);