diff options
Diffstat (limited to 'dev/Kernel/NewKit/Array.h')
| -rw-r--r-- | dev/Kernel/NewKit/Array.h | 58 |
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 |
