summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/NewKit/Array.h
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2025-01-24 10:38:36 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2025-01-24 10:38:36 +0100
commit7b4bd3577a31d0f0adc7371840642791ae1567f4 (patch)
tree1a8afc973aaa739d0d763315cad2fd376d1cea9c /dev/Kernel/NewKit/Array.h
ADD: Open version, with important changes kept out.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/NewKit/Array.h')
-rw-r--r--dev/Kernel/NewKit/Array.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/dev/Kernel/NewKit/Array.h b/dev/Kernel/NewKit/Array.h
new file mode 100644
index 00000000..c8ac6f55
--- /dev/null
+++ b/dev/Kernel/NewKit/Array.h
@@ -0,0 +1,58 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <KernelKit/DebugOutput.h>
+#include <NewKit/ErrorOr.h>
+#include <NewKit/Defines.h>
+
+namespace Kernel
+{
+ template <typename T, SizeT N>
+ class Array final
+ {
+ public:
+ explicit Array() = default;
+ ~Array() = default;
+
+ Array& operator=(const Array&) = default;
+ Array(const Array&) = default;
+
+ T& operator[](const SizeT& at)
+ {
+ return fArray[at];
+ }
+
+ Boolean Empty()
+ {
+ return this->Count() > 0;
+ }
+
+ const SizeT Capacity()
+ {
+ return N;
+ }
+
+ const SizeT Count()
+ {
+ return N;
+ }
+
+ const T* CData()
+ {
+ return fArray;
+ }
+
+ operator bool()
+ {
+ return !Empty();
+ }
+
+ private:
+ T fArray[N];
+ };
+} // namespace Kernel