diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2025-02-17 08:11:16 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2025-02-17 08:11:16 +0100 |
| commit | 2a2c3d58388579d19a7310684521dc57299969d2 (patch) | |
| tree | a638ed7922ef33f53ad55810c22ad6dc0f47dbfd /dev | |
| parent | a89eca1c9755eb781ab49572612afa90dfa6ea31 (diff) | |
ADD: Atom.h in LibCF, Atom.h in NewKit and LibCF stores the value as a bit.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Kernel/NewKit/Atom.h | 8 | ||||
| -rw-r--r-- | dev/Usr/LibCF/Atom.h | 47 |
2 files changed, 51 insertions, 4 deletions
diff --git a/dev/Kernel/NewKit/Atom.h b/dev/Kernel/NewKit/Atom.h index a90ef003..6845aee8 100644 --- a/dev/Kernel/NewKit/Atom.h +++ b/dev/Kernel/NewKit/Atom.h @@ -21,13 +21,13 @@ namespace Kernel Atom(const Atom&) = delete; public: - T operator[](Size sz) + T operator[](Size bit) { - return (fArrayOfAtoms & sz); + return (fArrayOfAtoms & (1 << bit)); } - void operator|(Size sz) + void operator|(Size bit) { - fArrayOfAtoms |= sz; + fArrayOfAtoms |= (1 << bit); } friend Boolean operator==(Atom<T>& atomic, const T& idx) diff --git a/dev/Usr/LibCF/Atom.h b/dev/Usr/LibCF/Atom.h new file mode 100644 index 00000000..9dde247e --- /dev/null +++ b/dev/Usr/LibCF/Atom.h @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ +#pragma once + +#include <LibCF/Core.h> + +namespace LibCF +{ + template <typename T> + class CFAtom final + { + public: + explicit CFAtom() = default; + ~CFAtom() = default; + + public: + CFAtom& operator=(const CFAtom&) = delete; + CFAtom(const CFAtom&) = delete; + + public: + T operator[](SizeT bit) + { + return (fArrayOfAtoms & (1 << bit)); + } + + void operator|(SizeT bit) + { + fArrayOfAtoms |= (1 << bit); + } + + friend Boolean operator==(CFAtom<T>& atomic, const T& idx) + { + return atomic[idx] == idx; + } + + friend Boolean operator!=(CFAtom<T>& atomic, const T& idx) + { + return atomic[idx] == idx; + } + + private: + T fArrayOfAtoms; + }; +} // namespace LibCF |
