From 09dd11ddf800898c00ecb04a65fb5cd10fb481fa Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 8 May 2024 12:32:41 +0200 Subject: MHR-23: :boom: changes, reworked project tree. Signed-off-by: Amlal El Mahrouss --- NewKernel/NewKit/Array.hpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 NewKernel/NewKit/Array.hpp (limited to 'NewKernel/NewKit/Array.hpp') diff --git a/NewKernel/NewKit/Array.hpp b/NewKernel/NewKit/Array.hpp new file mode 100644 index 00000000..1799e025 --- /dev/null +++ b/NewKernel/NewKit/Array.hpp @@ -0,0 +1,69 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ +#pragma once + +#include +#include +#include + +namespace NewOS +{ + template + class Array final + { + public: + explicit Array() = default; + ~Array() = default; + + Array& operator=(const Array&) = default; + Array(const Array&) = default; + + ErrorOr operator[](Size At) + { + if (At > N) + return {}; + + kcout << "Returning element\r"; + return ErrorOr(fArray[At]); + } + + Boolean Empty() const + { + for (auto Val : fArray) + { + if (Val) + return false; + } + + return true; + } + + SizeT Count() const + { + SizeT cntElems = 0UL; + for (auto Val : fArray) + { + if (Val) + ++cntElems; + } + + return cntElems; + } + + const T* CData() + { + return fArray; + } + + operator bool() + { + return !Empty(); + } + + private: + T fArray[N]; + }; +} // namespace NewOS -- cgit v1.2.3