summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/NewKit/Array.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Kernel/NewKit/Array.hxx')
-rw-r--r--dev/Kernel/NewKit/Array.hxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/dev/Kernel/NewKit/Array.hxx b/dev/Kernel/NewKit/Array.hxx
new file mode 100644
index 00000000..1a2f6e86
--- /dev/null
+++ b/dev/Kernel/NewKit/Array.hxx
@@ -0,0 +1,61 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+#pragma once
+
+#include <KernelKit/DebugOutput.hxx>
+#include <NewKit/ErrorOr.hxx>
+#include <NewKit/Defines.hxx>
+
+namespace Kernel
+{
+ template <typename T, Size N>
+ class Array final
+ {
+ public:
+ explicit Array() = default;
+ ~Array() = default;
+
+ Array& operator=(const Array&) = default;
+ Array(const Array&) = default;
+
+ ErrorOr<T*> operator[](Size At)
+ {
+ if (At > N)
+ return {};
+
+ return ErrorOr<T*>(&fArray[At]);
+ }
+
+ Boolean Empty() const
+ {
+ for (auto Val : fArray)
+ {
+ if (Val)
+ return false;
+ }
+
+ return true;
+ }
+
+ SizeT Count() const
+ {
+ return N;
+ }
+
+ const T* CData()
+ {
+ return fArray;
+ }
+
+ operator bool()
+ {
+ return !Empty();
+ }
+
+ private:
+ T fArray[N];
+ };
+} // namespace Kernel