From 610f91d87152cbe48d3054fcf437d8239da6ef35 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 21 Dec 2024 21:59:13 +0100 Subject: IMP: :boom: Breaking changes some checks are needed to be done. Signed-off-by: Amlal --- dev/Kernel/NewKit/Array.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 dev/Kernel/NewKit/Array.h (limited to 'dev/Kernel/NewKit/Array.h') diff --git a/dev/Kernel/NewKit/Array.h b/dev/Kernel/NewKit/Array.h new file mode 100644 index 00000000..6c69536e --- /dev/null +++ b/dev/Kernel/NewKit/Array.h @@ -0,0 +1,72 @@ +/* ------------------------------------------- + + Copyright (C) 2024, TQ B.V, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +namespace Kernel +{ + template + 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]; + } + + T Assign(const SizeT& At, T NewVal) + { + fArray[At] = NewVal; + return fArray[At]; + } + + Boolean Empty() + { + return this->Count() > 0; + } + + 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 -- cgit v1.2.3