Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
4756017
Adjust file paths
Mozz3d Feb 7, 2025
880f4bd
Improve Container Types
Mozz3d Feb 7, 2025
b6f4513
Fix include path
Mozz3d Feb 7, 2025
937f56d
Adjustments
Mozz3d Feb 7, 2025
6080dc9
Several improvements & adjustments
Mozz3d Feb 11, 2025
00a2473
Fix mistake & ArrayIterator crediting
Mozz3d Feb 11, 2025
3ae9d42
Fix errors
Mozz3d Feb 11, 2025
9a904b4
Fix compiler warning
Mozz3d Feb 11, 2025
ca50d24
Several adjustments
Mozz3d Feb 14, 2025
52c2085
Move SortedArray.hpp
Mozz3d Feb 14, 2025
8d95b35
Adjust include in TweakDB.hpp
Mozz3d Feb 14, 2025
b837509
Fixes and cleanup
Mozz3d Feb 14, 2025
4a0fa19
More adjustments
Mozz3d Feb 14, 2025
bd9f667
Several more improvments
Mozz3d Feb 20, 2025
bf62ff2
Some fixes and minor improvement
Mozz3d Mar 12, 2025
6b00245
DynArray Buffer Move & Semantic Improvements
Mozz3d Apr 8, 2025
27a4550
Fix errors
Mozz3d Apr 8, 2025
619c6e5
Use `MoveEntries` only if `ValueType` is not trivially relocatable
Mozz3d Apr 8, 2025
2835e65
Update `DynArray_Realloc` signature
Mozz3d Apr 8, 2025
40ebc21
Fix instantiation (I think?)
Mozz3d Apr 8, 2025
690fc40
Fix syntax
Mozz3d Apr 8, 2025
5d88695
Fix my sheer stupidity
Mozz3d Apr 8, 2025
0c9d751
Rename iterator based `Contains` to `Includes` & make private
Mozz3d Apr 8, 2025
608b776
Fix StaticArray::Resize & improve empty check semantics
Mozz3d May 21, 2025
674368e
Merge remote-tracking branch 'upstream/master' into pr/180
Mozz3d May 21, 2025
406f4ed
Merge branch 'master' into master
Mozz3d Jul 27, 2025
1f2bbe8
Suggested changes
Mozz3d Jul 27, 2025
b0a2d8e
Merge branch 'master' into master
Mozz3d Jul 27, 2025
5d88f9d
Semantic improvments
Mozz3d Jul 27, 2025
ed91925
Merge branch 'master' of https://github.com/Mozz3d/RED4ext.SDK
Mozz3d Jul 27, 2025
2c86e1b
STL compatibility for `Span` & `StaticArray`
Mozz3d Jul 27, 2025
2ad0010
Prefix member names in `StaticArray`
Mozz3d Jul 27, 2025
a46e140
Suggested changes
Mozz3d Aug 11, 2025
f1b1a60
Remove duplicate `Find` definitions
Mozz3d Aug 11, 2025
f5a33e9
Keep `min` `max` macros undefine
Mozz3d Aug 11, 2025
eef7358
Keep const and non-const `Find` implementations
Mozz3d Aug 11, 2025
9a8c307
Keep explicit `ConstIterator` cast in `DynArray::Emplace`
Mozz3d Aug 11, 2025
50714ea
Fix naming in `StaticArray`
Mozz3d Aug 11, 2025
31dd07c
Fix duplicate `Find` definition in `StaticArray`
Mozz3d Aug 11, 2025
7d4f16e
Remove whitespace
Mozz3d Aug 12, 2025
6926840
Try wrapping `std::min` to avoid macro conflict
Mozz3d Aug 12, 2025
22afb86
Try again
Mozz3d Aug 12, 2025
b9fe311
Appease clang formatting
Mozz3d Aug 12, 2025
5459be3
Update dumps for 2.3
Mozz3d Aug 13, 2025
1d78723
Remove accidental CET dump
Mozz3d Aug 13, 2025
f11491b
Move generic includes down
Mozz3d Aug 19, 2025
0459bc2
Merge branch 'master' into master
Mozz3d Jan 7, 2026
84afac9
Fix use of outdated method in `TagList::Contains`
Mozz3d Jan 7, 2026
3c9437c
Improve semantics
Mozz3d Jan 16, 2026
d460d8f
Avoid `max` macro conflict
Mozz3d Jan 16, 2026
8a0c7a7
Use explicit `SizeType` casts & improve constness
Mozz3d Jan 16, 2026
f8682e6
Outdated method name
Mozz3d Jan 16, 2026
aab87ac
Too lazy to reinstall clang prehook so this is what I get
Mozz3d Jan 16, 2026
70e8839
Merge branch 'master' into master
Mozz3d Feb 19, 2026
d646f7f
Method renaming
Mozz3d Feb 22, 2026
257ab19
Merge branch 'master' of https://github.com/Mozz3d/RED4ext.SDK
Mozz3d Feb 22, 2026
22afae8
Fix uses of `Empty`->`IsEmpty`
Mozz3d Feb 22, 2026
67234dd
Merge remote-tracking branch 'upstream/master'
Mozz3d Feb 23, 2026
dfbf0ae
Merge branch 'master' into master
Mozz3d Mar 9, 2026
76dc900
Update Changelog
Mozz3d Mar 13, 2026
d9869e7
Improve changelog according to feedback
Mozz3d Mar 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
518 changes: 518 additions & 0 deletions include/RED4ext/Containers/DynArray.hpp

Large diffs are not rendered by default.

246 changes: 246 additions & 0 deletions include/RED4ext/Containers/Span.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
#pragma once

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <stdexcept>

#include <RED4ext/Common.hpp>
#include <RED4ext/Detail/Containers/ArrayIterator.hpp>

namespace RED4ext
{
template<typename T>
struct Span
{
using ValueType = T;
using Reference = ValueType&;
using ConstReference = const Reference;
using Pointer = ValueType*;
using ConstPointer = const Pointer;

using SizeType = std::uint32_t;
using DifferenceType = std::ptrdiff_t;

using Iterator = Detail::ArrayIterator<ValueType, Span>;
using ConstIterator = Detail::ArrayIterator<const ValueType, Span>;
using ReverseIterator = std::reverse_iterator<Iterator>;
using ConstReverseIterator = std::reverse_iterator<ConstIterator>;

Span()
: beginPtr(nullptr)
, endPtr(nullptr)
{
}

Span(Pointer aBegin, Pointer aEnd)
: beginPtr(aBegin)
, endPtr(aEnd)
{
}

Span(Pointer aBegin, SizeType aCount)
: beginPtr(aBegin)
, endPtr(aBegin + aCount)
{
}

constexpr Reference operator[](SizeType aPos)
{
assert(aPos < Size());
return Data()[aPos];
}

constexpr ConstReference operator[](SizeType aPos) const
{
assert(aPos < Size());
return Data()[aPos];
}

[[nodiscard]] constexpr Reference At(SizeType aPos)
{
if (aPos >= Size())
throw std::out_of_range("Span::At: out of range");

return Data()[aPos];
}

[[nodiscard]] constexpr ConstReference At(SizeType aPos) const
{
if (aPos >= Size())
throw std::out_of_range("Span::At: out of range");

return Data()[aPos];
}

[[nodiscard]] constexpr Iterator Find(ConstReference aValue) noexcept
{
return Iterator(std::find(Begin(), End(), aValue));
}

[[nodiscard]] constexpr ConstIterator Find(ConstReference aValue) const noexcept
{
return ConstIterator(std::find(Begin(), End(), aValue));
}

[[nodiscard]] constexpr bool Contains(ConstReference aValue) const noexcept
{
return Find(aValue) != End();
}

[[nodiscard]] constexpr Reference Front()
{
assert(!Empty());
return Data()[0];
}

[[nodiscard]] constexpr ConstReference Front() const
{
assert(!Empty());
return Data()[0];
}

[[nodiscard]] constexpr Reference Back()
{
assert(!Empty());
return Data()[Size() - 1];
}

[[nodiscard]] constexpr ConstReference Back() const
{
assert(!Empty());
return Data()[Size() - 1];
}

[[nodiscard]] constexpr Iterator Begin() noexcept
{
return beginPtr;
}

[[nodiscard]] constexpr ConstIterator Begin() const noexcept
{
return beginPtr;
}

[[nodiscard]] constexpr ReverseIterator RBegin() noexcept
{
return ReverseIterator(Begin());
}

[[nodiscard]] constexpr ConstReverseIterator RBegin() const noexcept
{
return ConstReverseIterator(Begin());
}

[[nodiscard]] constexpr Iterator End() noexcept
{
return endPtr;
}

[[nodiscard]] constexpr ConstIterator End() const noexcept
{
return endPtr;
}

[[nodiscard]] constexpr ReverseIterator REnd() noexcept
{
return ReverseIterator(End());
}

[[nodiscard]] constexpr ConstReverseIterator REnd() const noexcept
{
return ConstReverseIterator(End());
}

[[nodiscard]] constexpr bool Empty() const
{
return Size() == 0;
}

[[nodiscard]] constexpr Pointer Data() noexcept
{
return beginPtr;
}

[[nodiscard]] constexpr ConstPointer Data() const noexcept
{
return beginPtr;
}

[[nodiscard]] constexpr DifferenceType Size() const
{
return endPtr - beginPtr;
}

T* beginPtr; // 00
T* endPtr; // 08

#pragma region STL
#pragma region Iterator
[[nodiscard]] constexpr Iterator begin() noexcept
{
return Begin();
}

[[nodiscard]] constexpr ConstIterator begin() const noexcept
{
return Begin();
}

[[nodiscard]] constexpr ConstIterator cbegin() const noexcept
{
return Begin();
}

[[nodiscard]] constexpr Iterator end() noexcept
{
return End();
}

[[nodiscard]] constexpr ConstIterator end() const noexcept
{
return End();
}

[[nodiscard]] constexpr ConstIterator cend() const noexcept
{
return End();
}
#pragma endregion
#pragma region Reverse Iterator
[[nodiscard]] constexpr ReverseIterator rbegin() noexcept
{
return RBegin();
}

[[nodiscard]] constexpr ConstReverseIterator rbegin() const noexcept
{
return RBegin();
}

[[nodiscard]] constexpr ConstReverseIterator crbegin() const
{
return RBegin();
}

[[nodiscard]] constexpr ReverseIterator rend() noexcept
{
return REnd();
}

[[nodiscard]] constexpr ConstReverseIterator rend() const noexcept
{
return REnd();
}

[[nodiscard]] constexpr ConstReverseIterator crend() const noexcept
{
return REnd();
}
#pragma endregion
#pragma endregion
};
RED4EXT_ASSERT_SIZE(Span<int32_t>, 0x10);
RED4EXT_ASSERT_OFFSET(Span<int32_t>, beginPtr, 0x0);
RED4EXT_ASSERT_OFFSET(Span<int32_t>, endPtr, 0x8);
} // namespace RED4ext
Loading