-
Notifications
You must be signed in to change notification settings - Fork 42
Improve Container Types #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mozz3d
wants to merge
61
commits into
wopss:master
Choose a base branch
from
Mozz3d:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
4756017
Adjust file paths
Mozz3d 880f4bd
Improve Container Types
Mozz3d b6f4513
Fix include path
Mozz3d 937f56d
Adjustments
Mozz3d 6080dc9
Several improvements & adjustments
Mozz3d 00a2473
Fix mistake & ArrayIterator crediting
Mozz3d 3ae9d42
Fix errors
Mozz3d 9a904b4
Fix compiler warning
Mozz3d ca50d24
Several adjustments
Mozz3d 52c2085
Move SortedArray.hpp
Mozz3d 8d95b35
Adjust include in TweakDB.hpp
Mozz3d b837509
Fixes and cleanup
Mozz3d 4a0fa19
More adjustments
Mozz3d bd9f667
Several more improvments
Mozz3d bf62ff2
Some fixes and minor improvement
Mozz3d 6b00245
DynArray Buffer Move & Semantic Improvements
Mozz3d 27a4550
Fix errors
Mozz3d 619c6e5
Use `MoveEntries` only if `ValueType` is not trivially relocatable
Mozz3d 2835e65
Update `DynArray_Realloc` signature
Mozz3d 40ebc21
Fix instantiation (I think?)
Mozz3d 690fc40
Fix syntax
Mozz3d 5d88695
Fix my sheer stupidity
Mozz3d 0c9d751
Rename iterator based `Contains` to `Includes` & make private
Mozz3d 608b776
Fix StaticArray::Resize & improve empty check semantics
Mozz3d 674368e
Merge remote-tracking branch 'upstream/master' into pr/180
Mozz3d 406f4ed
Merge branch 'master' into master
Mozz3d 1f2bbe8
Suggested changes
Mozz3d b0a2d8e
Merge branch 'master' into master
Mozz3d 5d88f9d
Semantic improvments
Mozz3d ed91925
Merge branch 'master' of https://github.com/Mozz3d/RED4ext.SDK
Mozz3d 2c86e1b
STL compatibility for `Span` & `StaticArray`
Mozz3d 2ad0010
Prefix member names in `StaticArray`
Mozz3d a46e140
Suggested changes
Mozz3d f1b1a60
Remove duplicate `Find` definitions
Mozz3d f5a33e9
Keep `min` `max` macros undefine
Mozz3d eef7358
Keep const and non-const `Find` implementations
Mozz3d 9a8c307
Keep explicit `ConstIterator` cast in `DynArray::Emplace`
Mozz3d 50714ea
Fix naming in `StaticArray`
Mozz3d 31dd07c
Fix duplicate `Find` definition in `StaticArray`
Mozz3d 7d4f16e
Remove whitespace
Mozz3d 6926840
Try wrapping `std::min` to avoid macro conflict
Mozz3d 22afb86
Try again
Mozz3d b9fe311
Appease clang formatting
Mozz3d 5459be3
Update dumps for 2.3
Mozz3d 1d78723
Remove accidental CET dump
Mozz3d f11491b
Move generic includes down
Mozz3d 0459bc2
Merge branch 'master' into master
Mozz3d 84afac9
Fix use of outdated method in `TagList::Contains`
Mozz3d 3c9437c
Improve semantics
Mozz3d d460d8f
Avoid `max` macro conflict
Mozz3d 8a0c7a7
Use explicit `SizeType` casts & improve constness
Mozz3d f8682e6
Outdated method name
Mozz3d aab87ac
Too lazy to reinstall clang prehook so this is what I get
Mozz3d 70e8839
Merge branch 'master' into master
Mozz3d d646f7f
Method renaming
Mozz3d 257ab19
Merge branch 'master' of https://github.com/Mozz3d/RED4ext.SDK
Mozz3d 22afae8
Fix uses of `Empty`->`IsEmpty`
Mozz3d 67234dd
Merge remote-tracking branch 'upstream/master'
Mozz3d dfbf0ae
Merge branch 'master' into master
Mozz3d 76dc900
Update Changelog
Mozz3d d9869e7
Improve changelog according to feedback
Mozz3d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.