diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-18 21:39:29 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-18 21:39:29 +0200 |
| commit | da70596895d8135e08f8caac6978117697b4c021 (patch) | |
| tree | 2516785b5434df8453687f05dc8dd877438901ab /dev/ZKA/NewKit/Array.hxx | |
| parent | 005de79004c9d30e64bdee6e14e06f9d47d1f2ab (diff) | |
[REFACTOR]
Improved project structure.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/NewKit/Array.hxx')
| -rw-r--r-- | dev/ZKA/NewKit/Array.hxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dev/ZKA/NewKit/Array.hxx b/dev/ZKA/NewKit/Array.hxx new file mode 100644 index 00000000..1a2f6e86 --- /dev/null +++ b/dev/ZKA/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 |
