From a92422e8b28eec91c570f565e1c23bd566a61858 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Fri, 20 Dec 2024 18:09:27 +0800 Subject: [PATCH] refactor(*): refactor the tool library's namespace to plural form --- .../Source/Private/Testing/Algorithms.cpp | 10 +- .../Source/Private/Testing/Ranges.cpp | 116 +++++++++--------- .../Source/Public/Algorithms/Basic.h | 13 +- .../Source/Public/Containers/Array.h | 38 +++--- .../Source/Public/Containers/Bitset.h | 14 +-- .../Source/Public/Containers/List.h | 24 ++-- .../Memory/{Allocator.h => Allocators.h} | 0 Redcraft.Utility/Source/Public/Numerics/Bit.h | 2 +- .../Public/Numerics/{Literal.h => Literals.h} | 0 .../Source/Public/Numerics/Numerics.h | 2 +- .../Source/Public/Ranges/AllView.h | 52 ++++---- .../Source/Public/Ranges/Conversion.h | 22 ++-- .../Source/Public/Ranges/Factory.h | 20 +-- .../Source/Public/Ranges/FilterView.h | 16 +-- .../Source/Public/Ranges/MoveView.h | 30 ++--- Redcraft.Utility/Source/Public/Ranges/Pipe.h | 4 +- .../Source/Public/Ranges/TakeView.h | 38 +++--- .../Source/Public/Ranges/TakeWhileView.h | 20 +-- .../Source/Public/Ranges/TransformView.h | 28 ++--- .../Source/Public/Ranges/Utility.h | 50 ++++---- Redcraft.Utility/Source/Public/Ranges/View.h | 62 +++++----- .../Source/Public/Strings/Conversion.h.inl | 10 +- .../Source/Public/Strings/String.h | 22 ++-- .../Source/Public/Strings/StringView.h | 2 +- .../Source/Public/Templates/Variant.h | 2 +- 25 files changed, 299 insertions(+), 298 deletions(-) rename Redcraft.Utility/Source/Public/Memory/{Allocator.h => Allocators.h} (100%) rename Redcraft.Utility/Source/Public/Numerics/{Literal.h => Literals.h} (100%) diff --git a/Redcraft.Utility/Source/Private/Testing/Algorithms.cpp b/Redcraft.Utility/Source/Private/Testing/Algorithms.cpp index c1f731a..6e60565 100644 --- a/Redcraft.Utility/Source/Private/Testing/Algorithms.cpp +++ b/Redcraft.Utility/Source/Private/Testing/Algorithms.cpp @@ -19,16 +19,16 @@ void TestBasic() auto Iter = Arr.Begin(); - Algorithm::Advance(Iter, 5); + Algorithms::Advance(Iter, 5); always_check(*Iter == 5); - always_check(Algorithm::Distance(Arr.Begin(), Iter) == 5); + always_check(Algorithms::Distance(Arr.Begin(), Iter) == 5); - always_check(Algorithm::Distance(Arr) == 10); + always_check(Algorithms::Distance(Arr) == 10); - always_check(*Algorithm::Next(Iter, 2) == 7); - always_check(*Algorithm::Prev(Iter, 2) == 3); + always_check(*Algorithms::Next(Iter, 2) == 7); + always_check(*Algorithms::Prev(Iter, 2) == 3); } NAMESPACE_PRIVATE_END diff --git a/Redcraft.Utility/Source/Private/Testing/Ranges.cpp b/Redcraft.Utility/Source/Private/Testing/Ranges.cpp index a39e2fa..7535908 100644 --- a/Redcraft.Utility/Source/Private/Testing/Ranges.cpp +++ b/Redcraft.Utility/Source/Private/Testing/Ranges.cpp @@ -19,8 +19,8 @@ void TestConversion() const TArray Arr = { 1, 2, 3, 4, 5 }; const TList List = { 1, 2, 3, 4, 5 }; - const TArray Brr = Range::View(List.Begin(), List.End()) | Range::To>(); - const TList Mist = Range::View(Arr.Begin(), Arr.End()) | Range::To>(); + const TArray Brr = Ranges::View(List.Begin(), List.End()) | Ranges::To>(); + const TList Mist = Ranges::View(Arr.Begin(), Arr.End()) | Ranges::To>(); always_check(Arr == Brr); always_check(List == Mist); @@ -30,8 +30,8 @@ void TestConversion() const TArray Arr = { 1, 2, 3, 4, 5 }; const TList List = { 1, 2, 3, 4, 5 }; - const TArray Brr = Range::View(List.Begin(), List.End()) | Range::To(); - const TList Mist = Range::View(Arr.Begin(), Arr.End()) | Range::To(); + const TArray Brr = Ranges::View(List.Begin(), List.End()) | Ranges::To(); + const TList Mist = Ranges::View(Arr.Begin(), Arr.End()) | Ranges::To(); always_check(Arr == Brr); always_check(List == Mist); @@ -42,27 +42,27 @@ void TestFactory() { { const TArray Arr = { }; - const TArray Brr = Range::Empty | Range::To>(); + const TArray Brr = Ranges::Empty | Ranges::To>(); always_check(Arr == Brr); } { const TArray Arr = { 1 }; - const TArray Brr = Range::Single(1) | Range::To>(); + const TArray Brr = Ranges::Single(1) | Ranges::To>(); always_check(Arr == Brr); } { const TArray Arr = { 0, 1, 2, 3, 4 }; - const TArray Brr = Range::Iota(0, 5) | Range::To>(); + const TArray Brr = Ranges::Iota(0, 5) | Ranges::To>(); always_check(Arr == Brr); } { - auto View = Range::Iota(0, 5); + auto View = Ranges::Iota(0, 5); always_check(View.Num() == 5); always_check(!View.IsEmpty()); @@ -91,7 +91,7 @@ void TestFactory() } { - auto View = Range::Iota(0); + auto View = Ranges::Iota(0); always_check(!View.IsEmpty()); always_check(!!View); @@ -119,13 +119,13 @@ void TestFactory() { const TArray Arr = { 0, 0, 0, 0, 0 }; - const TArray Brr = Range::Repeat(0, 5) | Range::To>(); + const TArray Brr = Ranges::Repeat(0, 5) | Ranges::To>(); always_check(Arr == Brr); } { - auto View = Range::Repeat(0, 8); + auto View = Ranges::Repeat(0, 8); always_check(View.Num() == 8); always_check(!View.IsEmpty()); @@ -176,7 +176,7 @@ void TestFactory() } { - auto View = Range::Repeat(0); + auto View = Ranges::Repeat(0); always_check(!View.IsEmpty()); always_check(!!View); @@ -226,15 +226,15 @@ void TestAllView() { TArray Arr = { 0, 1, 2, 3, 4 }; - TArray Brr = Range::All(Arr) | Range::To>(); + TArray Brr = Ranges::All(Arr) | Ranges::To>(); always_check(Arr == Brr); - auto View = Range::All(MoveTemp(Arr)); + auto View = Ranges::All(MoveTemp(Arr)); Arr.Reset(); - TArray Crr = View | Range::To>(); + TArray Crr = View | Ranges::To>(); always_check(Brr == Crr); } @@ -254,7 +254,7 @@ void TestMoveView() FTracker Arr[2]; - auto View = Arr | Range::Move(); + auto View = Arr | Ranges::Move(); auto First = View.Begin(); auto Last = View.End(); @@ -269,7 +269,7 @@ void TestMoveView() { TArray Arr = { 0, 1, 2, 3, 4, 5, 6, 7 }; - auto View = Arr | Range::Move(); + auto View = Arr | Ranges::Move(); always_check(View.Num() == 8); always_check(!View.IsEmpty()); @@ -320,7 +320,7 @@ void TestMoveView() } { - auto View = Range::Iota(0) | Range::Move(); + auto View = Ranges::Iota(0) | Ranges::Move(); always_check(!View.IsEmpty()); always_check(!!View); @@ -354,8 +354,8 @@ void TestMiscView() TArray Brr = { 0, 2, 4, 6 }; TArray Crr = Arr - | Range::Filter([](int Value) { return Value % 2 == 0; }) - | Range::To>(); + | Ranges::Filter([](int Value) { return Value % 2 == 0; }) + | Ranges::To>(); always_check(Brr == Crr); } @@ -365,8 +365,8 @@ void TestMiscView() TArray Brr = { 0, 2, 4, 4, 2, 0 }; TArray Crr = Arr - | Range::Transform([](int Value) { return Value * 2; }) - | Range::To>(); + | Ranges::Transform([](int Value) { return Value * 2; }) + | Ranges::To>(); always_check(Brr == Crr); } @@ -376,14 +376,14 @@ void TestMiscView() TArray Brr = { 0, 2, 4, 4, 2, 0 }; TArray Crr = Arr - | Range::Filter ([](int Value) { return Value < 3; }) - | Range::Transform([](int Value) { return Value * 2; }) - | Range::To>(); + | Ranges::Filter ([](int Value) { return Value < 3; }) + | Ranges::Transform([](int Value) { return Value * 2; }) + | Ranges::To>(); TArray Drr = Arr - | Range::Transform([](int Value) { return Value * 2; }) - | Range::Filter ([](int Value) { return Value < 6; }) - | Range::To>(); + | Ranges::Transform([](int Value) { return Value * 2; }) + | Ranges::Filter ([](int Value) { return Value < 6; }) + | Ranges::To>(); always_check(Brr == Crr); always_check(Brr == Drr); @@ -392,13 +392,13 @@ void TestMiscView() { TArray Arr = { 0, 1, 2, 3, 4, 5, 6, 7 }; - TArray Brr = Range::Iota(0) - | Range::Take(8) - | Range::To>(); + TArray Brr = Ranges::Iota(0) + | Ranges::Take(8) + | Ranges::To>(); - TArray Crr = Range::Iota(0) - | Range::TakeWhile([](int Value) { return Value < 8; }) - | Range::To>(); + TArray Crr = Ranges::Iota(0) + | Ranges::TakeWhile([](int Value) { return Value < 8; }) + | Ranges::To>(); always_check(Arr == Brr); always_check(Arr == Crr); @@ -409,40 +409,40 @@ void TestMiscView() TArray Brr = { 0, 2, 4 }; TArray Crr = Arr - | Range::Filter ([](int Value) { return Value % 2 == 0; }) - | Range::Take(3) - | Range::Transform([](int Value) { return Value / 2; }) - | Range::To>(); + | Ranges::Filter ([](int Value) { return Value % 2 == 0; }) + | Ranges::Take(3) + | Ranges::Transform([](int Value) { return Value / 2; }) + | Ranges::To>(); TArray Drr = Arr - | Range::Filter ([](int Value) { return Value % 2 == 0; }) - | Range::TakeWhile([](int Value) { return Value < 10; }) - | Range::Transform([](int Value) { return Value / 2; }) - | Range::To>(); + | Ranges::Filter ([](int Value) { return Value % 2 == 0; }) + | Ranges::TakeWhile([](int Value) { return Value < 10; }) + | Ranges::Transform([](int Value) { return Value / 2; }) + | Ranges::To>(); TArray Err = Arr - | Range::Filter ([](int Value) { return Value % 2 == 0; }) - | Range::Transform([](int Value) { return Value / 2; }) - | Range::Take(3) - | Range::To>(); + | Ranges::Filter ([](int Value) { return Value % 2 == 0; }) + | Ranges::Transform([](int Value) { return Value / 2; }) + | Ranges::Take(3) + | Ranges::To>(); TArray Frr = Arr - | Range::Filter ([](int Value) { return Value % 2 == 0; }) - | Range::Transform([](int Value) { return Value / 2; }) - | Range::TakeWhile([](int Value) { return Value < 5; }) - | Range::To>(); + | Ranges::Filter ([](int Value) { return Value % 2 == 0; }) + | Ranges::Transform([](int Value) { return Value / 2; }) + | Ranges::TakeWhile([](int Value) { return Value < 5; }) + | Ranges::To>(); TArray Grr = Arr - | Range::Take(6) - | Range::Filter ([](int Value) { return Value % 2 == 0; }) - | Range::Transform([](int Value) { return Value / 2; }) - | Range::To>(); + | Ranges::Take(6) + | Ranges::Filter ([](int Value) { return Value % 2 == 0; }) + | Ranges::Transform([](int Value) { return Value / 2; }) + | Ranges::To>(); TArray Hrr = Arr - | Range::TakeWhile([](int Value) { return Value < 10; }) - | Range::Filter ([](int Value) { return Value % 2 == 0; }) - | Range::Transform([](int Value) { return Value / 2; }) - | Range::To>(); + | Ranges::TakeWhile([](int Value) { return Value < 10; }) + | Ranges::Filter ([](int Value) { return Value % 2 == 0; }) + | Ranges::Transform([](int Value) { return Value / 2; }) + | Ranges::To>(); always_check(Brr == Crr); always_check(Brr == Drr); diff --git a/Redcraft.Utility/Source/Public/Algorithms/Basic.h b/Redcraft.Utility/Source/Public/Algorithms/Basic.h index 1316dde..59376d0 100644 --- a/Redcraft.Utility/Source/Public/Algorithms/Basic.h +++ b/Redcraft.Utility/Source/Public/Algorithms/Basic.h @@ -3,6 +3,7 @@ #include "CoreTypes.h" #include "TypeTraits/TypeTraits.h" #include "Iterators/Utility.h" +#include "Iterators/Sentinel.h" #include "Iterators/BasicIterator.h" #include "Ranges/Utility.h" #include "Miscellaneous/AssertionMacros.h" @@ -11,7 +12,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -NAMESPACE_BEGIN(Algorithm) +NAMESPACE_BEGIN(Algorithms) /** Increments given iterator 'Iter' by 'N' elements. */ template @@ -57,16 +58,16 @@ NODISCARD FORCEINLINE constexpr ptrdiff Distance(R&& Range) { if constexpr (CSizedRange) { - return static_cast(Range::Num(Range)); + return static_cast(Ranges::Num(Range)); } - else return Algorithm::Distance(Range::Begin(Range), Range::End(Range)); + else return Algorithms::Distance(Ranges::Begin(Range), Ranges::End(Range)); } /** @return The 'N'-th successor of iterator 'Iter'. */ template NODISCARD FORCEINLINE constexpr I Next(I Iter, ptrdiff N = 1) { - Algorithm::Advance(Iter, N); + Algorithms::Advance(Iter, N); return Iter; } @@ -74,11 +75,11 @@ NODISCARD FORCEINLINE constexpr I Next(I Iter, ptrdiff N = 1) template NODISCARD FORCEINLINE constexpr I Prev(I Iter, ptrdiff N = 1) { - Algorithm::Advance(Iter, -N); + Algorithms::Advance(Iter, -N); return Iter; } -NAMESPACE_END(Algorithm) +NAMESPACE_END(Algorithms) NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Containers/Array.h b/Redcraft.Utility/Source/Public/Containers/Array.h index 2b83d1b..4687f0e 100644 --- a/Redcraft.Utility/Source/Public/Containers/Array.h +++ b/Redcraft.Utility/Source/Public/Containers/Array.h @@ -4,7 +4,7 @@ #include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" -#include "Memory/Allocator.h" +#include "Memory/Allocators.h" #include "Memory/MemoryOperator.h" #include "Iterators/Utility.h" #include "Iterators/BasicIterator.h" @@ -60,7 +60,7 @@ public: /** Constructs the container with 'Count' copies of elements with 'InValue'. */ FORCEINLINE explicit TArray(size_t Count, const FElementType& InValue) requires (CCopyConstructible) - : TArray(Range::Repeat(InValue, Count)) + : TArray(Ranges::Repeat(InValue, Count)) { } /** Constructs the container with the contents of the range ['First', 'Last'). */ @@ -104,7 +104,7 @@ public: /** Constructs the container with the contents of the range. */ template requires (!CSameAs, TArray> && CConstructibleFrom> && CMovable) - FORCEINLINE explicit TArray(R&& Range) : TArray(Range::Begin(Range), Range::End(Range)) { } + FORCEINLINE explicit TArray(R&& Range) : TArray(Ranges::Begin(Range), Ranges::End(Range)) { } /** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */ TArray(const TArray& InValue) requires (CCopyConstructible) @@ -142,7 +142,7 @@ public: } /** Constructs the container with the contents of the initializer list. */ - FORCEINLINE TArray(initializer_list IL) requires (CCopyConstructible) : TArray(Range::Begin(IL), Range::End(IL)) { } + FORCEINLINE TArray(initializer_list IL) requires (CCopyConstructible) : TArray(Ranges::Begin(IL), Ranges::End(IL)) { } /** Destructs the array. The destructors of the elements are called and the used storage is deallocated. */ ~TArray() @@ -256,38 +256,38 @@ public: /** Replaces the contents with those identified by initializer list. */ TArray& operator=(initializer_list IL) requires (CCopyable) { - size_t NumToAllocate = Range::Num(IL); + size_t NumToAllocate = Ranges::Num(IL); - NumToAllocate = NumToAllocate > Max() ? Impl->CalculateSlackGrow (Range::Num(IL), Max()) : NumToAllocate; - NumToAllocate = NumToAllocate < Max() ? Impl->CalculateSlackShrink(Range::Num(IL), Max()) : NumToAllocate; + NumToAllocate = NumToAllocate > Max() ? Impl->CalculateSlackGrow (Ranges::Num(IL), Max()) : NumToAllocate; + NumToAllocate = NumToAllocate < Max() ? Impl->CalculateSlackShrink(Ranges::Num(IL), Max()) : NumToAllocate; if (NumToAllocate != Max()) { Memory::Destruct(Impl.Pointer, Num()); Impl->Deallocate(Impl.Pointer); - Impl.ArrayNum = Range::Num(IL); + Impl.ArrayNum = Ranges::Num(IL); Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::CopyConstruct(Impl.Pointer, Range::GetData(IL), Num()); + Memory::CopyConstruct(Impl.Pointer, Ranges::GetData(IL), Num()); return *this; } - if (Range::Num(IL) <= Num()) + if (Ranges::Num(IL) <= Num()) { - Memory::CopyAssign(Impl.Pointer, Range::GetData(IL), Range::Num(IL)); - Memory::Destruct(Impl.Pointer + Range::Num(IL), Num() - Range::Num(IL)); + Memory::CopyAssign(Impl.Pointer, Ranges::GetData(IL), Ranges::Num(IL)); + Memory::Destruct(Impl.Pointer + Ranges::Num(IL), Num() - Ranges::Num(IL)); } - else if (Range::Num(IL) <= Max()) + else if (Ranges::Num(IL) <= Max()) { - Memory::CopyAssign(Impl.Pointer, Range::GetData(IL), Num()); - Memory::CopyConstruct(Impl.Pointer + Num(), Range::GetData(IL) + Num(), Range::Num(IL) - Num()); + Memory::CopyAssign(Impl.Pointer, Ranges::GetData(IL), Num()); + Memory::CopyConstruct(Impl.Pointer + Num(), Ranges::GetData(IL) + Num(), Ranges::Num(IL) - Num()); } else check_no_entry(); - Impl.ArrayNum = Range::Num(IL); + Impl.ArrayNum = Ranges::Num(IL); return *this; } @@ -419,7 +419,7 @@ public: { checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); - return Insert(Iter, Range::Repeat(InValue, Count)); + return Insert(Iter, Ranges::Repeat(InValue, Count)); } /** Inserts elements from range ['First', 'Last') before 'Iter'. */ @@ -546,13 +546,13 @@ public: template requires (CConstructibleFrom> && CAssignableFrom> && CMovable) FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range) { - return Insert(Iter, Range::Begin(Range), Range::End(Range)); + return Insert(Iter, Ranges::Begin(Range), Ranges::End(Range)); } /** Inserts elements from initializer list before 'Iter' in the container. */ FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list IL) requires (CCopyable) { - return Insert(Iter, Range::Begin(IL), Range::End(IL)); + return Insert(Iter, Ranges::Begin(IL), Ranges::End(IL)); } /** Inserts a new element into the container directly before 'Iter'. */ diff --git a/Redcraft.Utility/Source/Public/Containers/Bitset.h b/Redcraft.Utility/Source/Public/Containers/Bitset.h index e251b55..341ee2a 100644 --- a/Redcraft.Utility/Source/Public/Containers/Bitset.h +++ b/Redcraft.Utility/Source/Public/Containers/Bitset.h @@ -5,7 +5,7 @@ #include "Templates/Utility.h" #include "Templates/TypeHash.h" #include "Templates/Noncopyable.h" -#include "Memory/Allocator.h" +#include "Memory/Allocators.h" #include "Iterators/Utility.h" #include "Iterators/BasicIterator.h" #include "Iterators/Sentinel.h" @@ -135,7 +135,7 @@ public: /** Constructs the bitset with the bits of the range. */ template requires (!CSameAs, TBitset> && CConstructibleFrom>) - FORCEINLINE explicit TBitset(R&& Range) : TBitset(Range::Begin(Range), Range::End(Range)) { } + FORCEINLINE explicit TBitset(R&& Range) : TBitset(Ranges::Begin(Range), Ranges::End(Range)) { } /** Copy constructor. Constructs the bitset with the copy of the bits of 'InValue'. */ FORCEINLINE TBitset(const TBitset& InValue) @@ -171,7 +171,7 @@ public: } /** Constructs the bitset with the bits of the initializer list. */ - FORCEINLINE TBitset(initializer_list IL) : TBitset(Range::Begin(IL), Range::End(IL)) { } + FORCEINLINE TBitset(initializer_list IL) : TBitset(Ranges::Begin(IL), Ranges::End(IL)) { } /** Destructs the bitset. The storage is deallocated. */ ~TBitset() @@ -239,9 +239,9 @@ public: /** Replaces the bits with those identified by initializer list. */ TBitset& operator=(initializer_list IL) { - auto First = Range::Begin(IL); + auto First = Ranges::Begin(IL); - const size_t BlocksCount = (Range::Num(IL) + BlockWidth - 1) / BlockWidth; + const size_t BlocksCount = (Ranges::Num(IL) + BlockWidth - 1) / BlockWidth; size_t NumToAllocate = BlocksCount; @@ -252,7 +252,7 @@ public: { Impl->Deallocate(Impl.Pointer); - Impl.BitsetNum = Range::Num(IL); + Impl.BitsetNum = Ranges::Num(IL); Impl.BlocksMax = NumToAllocate; Impl.Pointer = Impl->Allocate(MaxBlocks()); @@ -261,7 +261,7 @@ public: return *this; } - Impl.BitsetNum = Range::Num(IL); + Impl.BitsetNum = Ranges::Num(IL); for (FReference Ref : *this) Ref = *First++; diff --git a/Redcraft.Utility/Source/Public/Containers/List.h b/Redcraft.Utility/Source/Public/Containers/List.h index 5ef2161..cc869fc 100644 --- a/Redcraft.Utility/Source/Public/Containers/List.h +++ b/Redcraft.Utility/Source/Public/Containers/List.h @@ -4,7 +4,7 @@ #include "TypeTraits/TypeTraits.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" -#include "Memory/Allocator.h" +#include "Memory/Allocators.h" #include "Memory/MemoryOperator.h" #include "Iterators/Utility.h" #include "Iterators/BasicIterator.h" @@ -79,7 +79,7 @@ public: /** Constructs the container with 'Count' copies of elements with 'InValue'. */ TList(size_t Count, const FElementType& InValue) requires (CCopyable) - : TList(Range::Repeat(InValue, Count)) + : TList(Ranges::Repeat(InValue, Count)) { } /** Constructs the container with the contents of the range ['First', 'Last'). */ @@ -106,7 +106,7 @@ public: /** Constructs the container with the contents of the range. */ template requires (!CSameAs, TList> && CConstructibleFrom>) - FORCEINLINE explicit TList(R&& Range) : TList(Range::Begin(Range), Range::End(Range)) { } + FORCEINLINE explicit TList(R&& Range) : TList(Ranges::Begin(Range), Ranges::End(Range)) { } /** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */ FORCEINLINE TList(const TList& InValue) requires (CCopyConstructible) : TList(InValue.Begin(), InValue.End()) { } @@ -115,7 +115,7 @@ public: FORCEINLINE TList(TList&& InValue) : TList() { Swap(*this, InValue); } /** Constructs the container with the contents of the initializer list. */ - FORCEINLINE TList(initializer_list IL) requires (CCopyConstructible) : TList(Range::Begin(IL), Range::End(IL)) { } + FORCEINLINE TList(initializer_list IL) requires (CCopyConstructible) : TList(Ranges::Begin(IL), Ranges::End(IL)) { } /** Destructs the list. The destructors of the elements are called and the used storage is deallocated. */ ~TList() @@ -176,9 +176,9 @@ public: TList& operator=(initializer_list IL) requires (CCopyable) { FIterator ThisIter = Begin(); - const FElementType* OtherIter = Range::Begin(IL); + const FElementType* OtherIter = Ranges::Begin(IL); - while (ThisIter != End() && OtherIter != Range::End(IL)) + while (ThisIter != End() && OtherIter != Ranges::End(IL)) { *ThisIter = *OtherIter; @@ -188,18 +188,18 @@ public: if (ThisIter == End()) { - while (OtherIter != Range::End(IL)) + while (OtherIter != Ranges::End(IL)) { EmplaceBack(*OtherIter); ++OtherIter; } } - else if (OtherIter == Range::End(IL)) + else if (OtherIter == Ranges::End(IL)) { Erase(ThisIter, End()); } - Impl.ListNum = Range::Num(IL); + Impl.ListNum = Ranges::Num(IL); return *this; } @@ -251,7 +251,7 @@ public: /** Inserts 'Count' copies of the 'InValue' before 'Iter' in the container. */ FIterator Insert(FConstIterator Iter, size_t Count, const FElementType& InValue) requires (CCopyConstructible) { - return Insert(Iter, Range::Repeat(InValue, Count)); + return Insert(Iter, Ranges::Repeat(InValue, Count)); } /** Inserts elements from range ['First', 'Last') before 'Iter'. */ @@ -291,10 +291,10 @@ public: /** Inserts elements from range ['First', 'Last') before 'Iter'. */ template requires (CConstructibleFrom>) - FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range) { return Insert(Iter, Range::Begin(Range), Range::End(Range)); } + FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range) { return Insert(Iter, Ranges::Begin(Range), Ranges::End(Range)); } /** Inserts elements from initializer list before 'Iter' in the container. */ - FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list IL) requires (CCopyConstructible) { return Insert(Iter, Range::Begin(IL), Range::End(IL)); } + FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list IL) requires (CCopyConstructible) { return Insert(Iter, Ranges::Begin(IL), Ranges::End(IL)); } /** Inserts a new element into the container directly before 'Iter'. */ template requires (CConstructibleFrom) diff --git a/Redcraft.Utility/Source/Public/Memory/Allocator.h b/Redcraft.Utility/Source/Public/Memory/Allocators.h similarity index 100% rename from Redcraft.Utility/Source/Public/Memory/Allocator.h rename to Redcraft.Utility/Source/Public/Memory/Allocators.h diff --git a/Redcraft.Utility/Source/Public/Numerics/Bit.h b/Redcraft.Utility/Source/Public/Numerics/Bit.h index 7450758..87b65d8 100644 --- a/Redcraft.Utility/Source/Public/Numerics/Bit.h +++ b/Redcraft.Utility/Source/Public/Numerics/Bit.h @@ -2,7 +2,7 @@ #include "CoreTypes.h" #include "Numerics/Limits.h" -#include "Numerics/Literal.h" +#include "Numerics/Literals.h" #include "TypeTraits/TypeTraits.h" #include diff --git a/Redcraft.Utility/Source/Public/Numerics/Literal.h b/Redcraft.Utility/Source/Public/Numerics/Literals.h similarity index 100% rename from Redcraft.Utility/Source/Public/Numerics/Literal.h rename to Redcraft.Utility/Source/Public/Numerics/Literals.h diff --git a/Redcraft.Utility/Source/Public/Numerics/Numerics.h b/Redcraft.Utility/Source/Public/Numerics/Numerics.h index 524def5..8d0c3a1 100644 --- a/Redcraft.Utility/Source/Public/Numerics/Numerics.h +++ b/Redcraft.Utility/Source/Public/Numerics/Numerics.h @@ -1,7 +1,7 @@ #pragma once #include "CoreTypes.h" -#include "Numerics/Literal.h" +#include "Numerics/Literals.h" #include "Numerics/Limits.h" #include "Numerics/Numbers.h" #include "Numerics/Bit.h" diff --git a/Redcraft.Utility/Source/Public/Ranges/AllView.h b/Redcraft.Utility/Source/Public/Ranges/AllView.h index 70441b1..a27f25d 100644 --- a/Redcraft.Utility/Source/Public/Ranges/AllView.h +++ b/Redcraft.Utility/Source/Public/Ranges/AllView.h @@ -11,7 +11,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -NAMESPACE_BEGIN(Range) +NAMESPACE_BEGIN(Ranges) /** * A view adapter that references other range. @@ -31,12 +31,12 @@ public: template requires (!CSameAs, TRefView> && CConvertibleTo && requires { Func(DeclVal()); }) FORCEINLINE constexpr TRefView(T&& InRange) : Ptr(AddressOf(static_cast(Forward(InRange)))) { } - NODISCARD FORCEINLINE constexpr TRangeIterator Begin() const { return Range::Begin(*Ptr); } - NODISCARD FORCEINLINE constexpr TRangeSentinel End() const { return Range::End (*Ptr); } + NODISCARD FORCEINLINE constexpr TRangeIterator Begin() const { return Ranges::Begin(*Ptr); } + NODISCARD FORCEINLINE constexpr TRangeSentinel End() const { return Ranges::End (*Ptr); } - NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange) { return Range::GetData(*Ptr); } - NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange) { return Range::Num (*Ptr); } - NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(R Range) { Range::IsEmpty(Range); }) { return Range::IsEmpty(*Ptr); } + NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange) { return Ranges::GetData(*Ptr); } + NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange) { return Ranges::Num (*Ptr); } + NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(R Range) { Ranges::IsEmpty(Range); }) { return Ranges::IsEmpty(*Ptr); } NODISCARD FORCEINLINE constexpr R& GetBase() const { return *Ptr; } @@ -61,12 +61,12 @@ static_assert( CView>>>) static_assert(COutputRange>>, int>); -NAMESPACE_END(Range) +NAMESPACE_END(Ranges) template -constexpr bool bEnableBorrowedRange> = true; +constexpr bool bEnableBorrowedRange> = true; -NAMESPACE_BEGIN(Range) +NAMESPACE_BEGIN(Ranges) /** * A view adapter that has unique ownership of a range. @@ -88,19 +88,19 @@ public: FORCEINLINE constexpr TOwningView& operator=(const TOwningView&) = delete; FORCEINLINE constexpr TOwningView& operator=(TOwningView&&) = default; - NODISCARD FORCEINLINE constexpr auto Begin() { return Range::Begin(Base); } - NODISCARD FORCEINLINE constexpr auto End() { return Range::End (Base); } - NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange) { return Range::Begin(Base); } - NODISCARD FORCEINLINE constexpr auto End() const requires (CRange) { return Range::End (Base); } + NODISCARD FORCEINLINE constexpr auto Begin() { return Ranges::Begin(Base); } + NODISCARD FORCEINLINE constexpr auto End() { return Ranges::End (Base); } + NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange) { return Ranges::Begin(Base); } + NODISCARD FORCEINLINE constexpr auto End() const requires (CRange) { return Ranges::End (Base); } - NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousRange< R>) { return Range::GetData(Base); } - NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange) { return Range::GetData(Base); } + NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousRange< R>) { return Ranges::GetData(Base); } + NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange) { return Ranges::GetData(Base); } - NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< R>) { return Range::Num(Base); } - NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange) { return Range::Num(Base); } + NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< R>) { return Ranges::Num(Base); } + NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange) { return Ranges::Num(Base); } - NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (requires( R Base) { Range::IsEmpty(Base); }) { return Range::IsEmpty(Base); } - NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(const R Base) { Range::IsEmpty(Base); }) { return Range::IsEmpty(Base); } + NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (requires( R Base) { Ranges::IsEmpty(Base); }) { return Ranges::IsEmpty(Base); } + NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(const R Base) { Ranges::IsEmpty(Base); }) { return Ranges::IsEmpty(Base); } NODISCARD FORCEINLINE constexpr R& GetBase() & { return Base; } NODISCARD FORCEINLINE constexpr R&& GetBase() && { return MoveTemp(Base); } @@ -125,12 +125,12 @@ static_assert( CView> static_assert(COutputRange>>, int>); -NAMESPACE_END(Range) +NAMESPACE_END(Ranges) template -constexpr bool bEnableBorrowedRange> = bEnableBorrowedRange; +constexpr bool bEnableBorrowedRange> = bEnableBorrowedRange; -NAMESPACE_BEGIN(Range) +NAMESPACE_BEGIN(Ranges) /** Creates A view adapter that includes all elements of a range. */ template @@ -152,9 +152,9 @@ NODISCARD FORCEINLINE constexpr auto All(R&& InRange) /** Creates A view adapter that includes all elements of a range. */ NODISCARD FORCEINLINE constexpr auto All() { - using FClosure = decltype([] requires (requires { Range::All(DeclVal()); }) (R&& Base) + using FClosure = decltype([] requires (requires { Ranges::All(DeclVal()); }) (R&& Base) { - return Range::All(Forward(Base)); + return Ranges::All(Forward(Base)); }); return TAdaptorClosure(); @@ -162,7 +162,7 @@ NODISCARD FORCEINLINE constexpr auto All() /** A view adapter that includes all elements of a range. */ template -using TAllView = decltype(Range::All(DeclVal())); +using TAllView = decltype(Ranges::All(DeclVal())); static_assert( CInputRange>>>); static_assert( CForwardRange>>>); @@ -176,7 +176,7 @@ static_assert( CView>>>) static_assert(COutputRange>>, int>); -NAMESPACE_END(Range) +NAMESPACE_END(Ranges) NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Ranges/Conversion.h b/Redcraft.Utility/Source/Public/Ranges/Conversion.h index 9b920d7..554cb05 100644 --- a/Redcraft.Utility/Source/Public/Ranges/Conversion.h +++ b/Redcraft.Utility/Source/Public/Ranges/Conversion.h @@ -49,7 +49,7 @@ concept CAppendableContainer = ); }; -NAMESPACE_BEGIN(Range) +NAMESPACE_BEGIN(Ranges) /** Constructs a non-view object from the elements of the range. */ template requires (!CView) @@ -64,7 +64,7 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args) else if constexpr (CCommonRange && CInputRange && CConstructibleFrom, TRangeSentinel, Ts...>) { - return C(Range::Begin(Range), Range::End(Range), Forward(Args)...); + return C(Ranges::Begin(Range), Ranges::End(Range), Forward(Args)...); } else if constexpr (CConstructibleFrom && CAppendableContainer>) @@ -73,7 +73,7 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args) if constexpr (CSizedRange && CReservableContainer) { - Result.Reserve(Range::Num(Range)); + Result.Reserve(Ranges::Num(Range)); } for (TRangeReference Element : Range) @@ -108,7 +108,7 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args) { if constexpr (CInputRange>) { - return Range::To(Range::All(Range) | Range::Transform([](T&& Element) { return Range::To>(Forward(Element)); }), Forward(Args)...); + return Ranges::To(Ranges::All(Range) | Ranges::Transform([](T&& Element) { return Ranges::To>(Forward(Element)); }), Forward(Args)...); } else static_assert(sizeof(R) == -1, "The container type is not constructible from a range"); @@ -121,12 +121,12 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args) { if constexpr (requires { C(DeclVal(), DeclVal()...); }) { - return Range::To(), DeclVal()...))>(Forward(Range), Forward(Args)...); + return Ranges::To(), DeclVal()...))>(Forward(Range), Forward(Args)...); } else if constexpr (requires { C(DeclVal>(), DeclVal>(), DeclVal()...); }) { - return Range::To>(), DeclVal>(), DeclVal()...))>(Forward(Range), Forward(Args)...); + return Ranges::To>(), DeclVal>(), DeclVal()...))>(Forward(Range), Forward(Args)...); } else static_assert(sizeof(R) == -1, "The container type is not constructible from a range"); @@ -136,9 +136,9 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args) template requires (!CView) NODISCARD FORCEINLINE constexpr auto To(Ts&&... Args) { - using FClosure = decltype([] requires (requires { Range::To(DeclVal(), DeclVal()...); }) (R&& Range, Us&&... Args) + using FClosure = decltype([] requires (requires { Ranges::To(DeclVal(), DeclVal()...); }) (R&& Range, Us&&... Args) { - return Range::To(Forward(Range), Forward(Args)...); + return Ranges::To(Forward(Range), Forward(Args)...); }); return TAdaptorClosure...>(Forward(Args)...); @@ -148,15 +148,15 @@ NODISCARD FORCEINLINE constexpr auto To(Ts&&... Args) template