fix(containers): fix operator<=> of TArray and TStaticArray to compare lexicographically
This commit is contained in:
parent
dd8b698bb3
commit
1daf90adee
@ -304,18 +304,15 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Compares the contents of two arrays. */
|
||||
/** Compares the contents of 'LHS' and 'RHS' lexicographically. */
|
||||
NODISCARD friend auto operator<=>(const TArray& LHS, const TArray& RHS) requires (CSynthThreeWayComparable<ElementType>)
|
||||
{
|
||||
using OrderingType = TSynthThreeWayResult<ElementType>;
|
||||
|
||||
if (LHS.Num() < RHS.Num()) return OrderingType::less;
|
||||
if (LHS.Num() > RHS.Num()) return OrderingType::greater;
|
||||
|
||||
ConstIterator LHSIter = LHS.Begin();
|
||||
ConstIterator RHSIter = RHS.Begin();
|
||||
|
||||
while (LHSIter != LHS.End())
|
||||
while (LHSIter != LHS.End() || RHSIter != RHS.End())
|
||||
{
|
||||
TSynthThreeWayResult<ElementType> Ordering = SynthThreeWayCompare(*LHSIter, *RHSIter);
|
||||
|
||||
@ -325,9 +322,7 @@ public:
|
||||
++RHSIter;
|
||||
}
|
||||
|
||||
check(RHSIter == RHS.End());
|
||||
|
||||
return OrderingType::equivalent;
|
||||
return LHS.Num() <=> RHS.Num();
|
||||
}
|
||||
|
||||
/** Inserts 'InValue' before 'Iter' in the container. */
|
||||
|
@ -62,18 +62,15 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Compares the contents of two arrays. */
|
||||
/** Compares the contents of 'LHS' and 'RHS' lexicographically. */
|
||||
NODISCARD friend constexpr auto operator<=>(const TStaticArray& LHS, const TStaticArray& RHS) requires (CSynthThreeWayComparable<ElementType>)
|
||||
{
|
||||
using OrderingType = TSynthThreeWayResult<ElementType>;
|
||||
|
||||
if (LHS.Num() < RHS.Num()) return OrderingType::less;
|
||||
if (LHS.Num() > RHS.Num()) return OrderingType::greater;
|
||||
|
||||
ConstIterator LHSIter = LHS.Begin();
|
||||
ConstIterator RHSIter = RHS.Begin();
|
||||
|
||||
while (LHSIter != LHS.End())
|
||||
while (LHSIter != LHS.End() || RHSIter != RHS.End())
|
||||
{
|
||||
TSynthThreeWayResult<ElementType> Ordering = SynthThreeWayCompare(*LHSIter, *RHSIter);
|
||||
|
||||
@ -83,9 +80,7 @@ public:
|
||||
++RHSIter;
|
||||
}
|
||||
|
||||
check(RHSIter == RHS.End());
|
||||
|
||||
return OrderingType::equivalent;
|
||||
return LHS.Num() <=> RHS.Num();
|
||||
}
|
||||
|
||||
/** @return The pointer to the underlying element storage. */
|
||||
|
Loading…
Reference in New Issue
Block a user