diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-22 17:46:11 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-22 17:46:11 +0200 |
| commit | 8719b4570a2d10dd49a0d3a47e24f5c55bdda85e (patch) | |
| tree | ba095740888f3768e08b2ea058b0ea6da2d0403d /dev/zka/NewKit/Array.hxx | |
| parent | 45944b3d2dab04b763fcc6d10164fe8069e60b08 (diff) | |
:boom: A big refactor on the filesystem structure.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/zka/NewKit/Array.hxx')
| -rw-r--r-- | dev/zka/NewKit/Array.hxx | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/dev/zka/NewKit/Array.hxx b/dev/zka/NewKit/Array.hxx new file mode 100644 index 00000000..7538ef02 --- /dev/null +++ b/dev/zka/NewKit/Array.hxx @@ -0,0 +1,73 @@ +/* ------------------------------------------- + + 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() + { + for (SizeT i = 0; i < N; i++) + { + if (!fArray[i]) + fArray[i] = T(); + } + } + + ~Array() = default; + + Array& operator=(const Array&) = default; + Array(const Array&) = default; + + T& operator[](const SizeT& At) + { + return fArray[At]; + } + + Boolean Empty() const + { + return No; + } + + const SizeT Capacity() + { + return N; + } + + const SizeT Count() + { + SizeT count = 0; + + for (SizeT i = 0; i < N; i++) + { + if (fArray[i]) + ++count; + } + + return count; + } + + const T* CData() + { + return fArray; + } + + operator bool() + { + return !Empty(); + } + + private: + T fArray[N]; + }; +} // namespace Kernel |
