diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-06 09:14:11 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-06 09:14:11 +0100 |
| commit | 5339d016c07bf717ee388f4feb73544087324af0 (patch) | |
| tree | 94be6f67ed626091f24aee24ec3b3be03d01e4e7 /NewKit/ArrayList.hpp | |
git: port from mercurial repo.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'NewKit/ArrayList.hpp')
| -rw-r--r-- | NewKit/ArrayList.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/NewKit/ArrayList.hpp b/NewKit/ArrayList.hpp new file mode 100644 index 00000000..20517d22 --- /dev/null +++ b/NewKit/ArrayList.hpp @@ -0,0 +1,60 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include <NewKit/Defines.hpp> + +namespace hCore +{ + template <typename T> + class ArrayList final + { + public: + explicit ArrayList(T *list) + : m_List(reinterpret_cast<T>(list)) + {} + + ~ArrayList() = default; + + ArrayList &operator=(const ArrayList &) = default; + ArrayList(const ArrayList &) = default; + + T *Data() + { + return m_List; + } + + const T *CData() + { + return m_List; + } + + T &operator[](int index) const + { + return m_List[index]; + } + + operator bool() + { + return m_List; + } + + private: + T *m_List; + + friend class InitHelpers; + + }; + + template <typename ValueType> ArrayList<ValueType> make_list(ValueType val) + { + return ArrayList<ValueType>{val}; + } +} // namespace hCore |
