summaryrefslogtreecommitdiff
path: root/AK/FixedArray.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-18 10:19:32 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-18 11:35:47 +0100
commita7dbb3cf96b049d66282350f4cb0ca65e4b0e9ea (patch)
treef5a36cd8d5bebba8308cd3a7303ee591b1146e0f /AK/FixedArray.h
parente0ecfc0c92a7e87efe32f3c2036e72b775141a56 (diff)
downloadserenity-a7dbb3cf96b049d66282350f4cb0ca65e4b0e9ea.zip
Kernel: Use a FixedArray for a process's extra GIDs
There's not really enough of these to justify using a HashTable.
Diffstat (limited to 'AK/FixedArray.h')
-rw-r--r--AK/FixedArray.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/AK/FixedArray.h b/AK/FixedArray.h
index b9dcc5ad12..7e86166746 100644
--- a/AK/FixedArray.h
+++ b/AK/FixedArray.h
@@ -54,7 +54,13 @@ public:
new (&m_elements[i]) T(other[i]);
}
- FixedArray& operator=(const FixedArray&) = delete;
+ FixedArray& operator=(const FixedArray& other)
+ {
+ FixedArray array(other);
+ swap(array);
+ return *this;
+ }
+
FixedArray(FixedArray&&) = delete;
FixedArray& operator=(FixedArray&&) = delete;
@@ -109,6 +115,21 @@ public:
m_size = new_size;
}
+ bool contains(const T& value) const
+ {
+ for (size_t i = 0; i < m_size; ++i) {
+ if (m_elements[i] == value)
+ return true;
+ }
+ return false;
+ }
+
+ void swap(FixedArray& other)
+ {
+ ::swap(m_elements, other.m_elements);
+ ::swap(m_size, other.m_size);
+ }
+
using Iterator = VectorIterator<FixedArray, T>;
Iterator begin() { return Iterator(*this, 0); }
Iterator end() { return Iterator(*this, size()); }