6#include "Containers/Array.h"
49template<
typename ElementType>
class TRange
112 return ((LowerBound ==
Other.LowerBound) && (UpperBound ==
Other.UpperBound));
128 return ((LowerBound !=
Other.LowerBound) || (UpperBound !=
Other.UpperBound));
347 return (LowerBound.
IsInclusive() && (LowerBound == UpperBound));
426 template<
typename DifferenceType>
530 if (Ranges.
Num() == 0)
535 TRange Bounds = Ranges[0];
537 for (
int32 i = 1; i < Ranges.
Num(); ++i)
539 Bounds =
Hull(Bounds, Ranges[i]);
579 if (Ranges.
Num() == 0)
584 TRange Bounds = Ranges[0];
586 for (
int32 i = 1; i < Ranges.
Num(); ++i)
737 return Ar << Range.LowerBound << Range.UpperBound;
764#define DEFINE_RANGE_WRAPPER_STRUCT(Name, ElementType) \
765 struct Name : TRange<ElementType> \
768 typedef TRange<ElementType> Super; \
776 Name(const Super& Rhs) \
781 explicit Name(ElementValueOrConstRef A) \
786 explicit Name(ElementValueOrConstRef A, ElementValueOrConstRef B) \
791 explicit Name(const TRangeBound<ElementType>& InLowerBound, const TRangeBound<ElementType>& InUpperBound) \
792 : Super(InLowerBound, InUpperBound) \
796 TArray<Name> Split(ElementValueOrConstRef Element) const \
798 return TArray<Name>(Super::Split(Element)); \
801 static UE_FORCEINLINE_HINT TArray<Name> Difference(const Name& X, const Name& Y) \
803 return TArray<Name>(Super::Difference(X, Y)); \
806 static UE_FORCEINLINE_HINT Name Empty() \
808 return Super::Empty(); \
811 static UE_FORCEINLINE_HINT Name Hull(const Name& X, const Name& Y) \
813 return Super::Hull(X, Y); \
816 static UE_FORCEINLINE_HINT Name Hull(const TArray<Name>& Ranges) \
818 return Super::Hull(reinterpret_cast<const TArray<Super>&>(Ranges)); \
821 static UE_FORCEINLINE_HINT Name Intersection(const Name& X, const Name& Y) \
823 return Super::Intersection(X, Y); \
826 static UE_FORCEINLINE_HINT Name Intersection(const TArray<Name>& Ranges) \
828 return Super::Intersection(reinterpret_cast<const TArray<Super>&>(Ranges)); \
831 static UE_FORCEINLINE_HINT TArray<Name> Union(const Name& X, const Name& Y) \
833 return TArray<Name>(Super::Union(X, Y)); \
836 static UE_FORCEINLINE_HINT Name All() \
838 return Super::All(); \
841 static UE_FORCEINLINE_HINT Name AtLeast(ElementValueOrConstRef Value) \
843 return Super::AtLeast(Value); \
846 static UE_FORCEINLINE_HINT Name AtMost(ElementValueOrConstRef Value) \
848 return Super::AtMost(Value); \
851 static UE_FORCEINLINE_HINT TRange GreaterThan(ElementValueOrConstRef Value) \
853 return Super::GreaterThan(Value); \
856 static UE_FORCEINLINE_HINT TRange LessThan(ElementValueOrConstRef Value) \
858 return Super::LessThan(Value); \
863 struct TIsBitwiseConstructible<Name, TRange<ElementType>> \
865 enum { Value = true }; \
869 struct TIsBitwiseConstructible<TRange<ElementType>, Name> \
871 enum { Value = true }; \
#define check(expr)
Definition AssertionMacros.h:314
#define DEFINE_RANGE_WRAPPER_STRUCT(Name, ElementType)
Definition Range.h:764
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Archive.h:1208
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition RangeBound.h:36
ElementValueOrConstRef GetValue() const
Definition RangeBound.h:97
UE_FORCEINLINE_HINT bool IsClosed() const
Definition RangeBound.h:125
static const TRangeBound & MinLower(const TRangeBound &A, const TRangeBound &B)
Definition RangeBound.h:300
UE_FORCEINLINE_HINT bool IsExclusive() const
Definition RangeBound.h:135
static const TRangeBound & MaxUpper(const TRangeBound &A, const TRangeBound &B)
Definition RangeBound.h:282
static TRangeBound Inclusive(ElementValueOrConstRef Value)
Definition RangeBound.h:209
UE_FORCEINLINE_HINT bool IsInclusive() const
Definition RangeBound.h:145
UE_FORCEINLINE_HINT bool IsOpen() const
Definition RangeBound.h:155
static const TRangeBound & MaxLower(const TRangeBound &A, const TRangeBound &B)
Definition RangeBound.h:264
static const TRangeBound & MinUpper(const TRangeBound &A, const TRangeBound &B)
Definition RangeBound.h:318
static TRangeBound FlipInclusion(const TRangeBound &Bound)
Definition RangeBound.h:242
static TRangeBound Open()
Definition RangeBound.h:224
static TRangeBound Exclusive(ElementValueOrConstRef Value)
Definition RangeBound.h:193
void SetValue(ElementValueOrConstRef NewValue)
Definition RangeBound.h:113
TCallTraits< ElementType >::ParamType ElementValueOrConstRef
Definition Range.h:56
bool Contains(ElementValueOrConstRef Element) const
Definition Range.h:191
TRange()
Definition Range.h:59
bool HasLowerBound() const
Definition Range.h:320
static UE_FORCEINLINE_HINT TRange Inclusive(ElementValueOrConstRef Min, ElementValueOrConstRef Max)
Definition Range.h:709
bool Overlaps(const TRange &Other) const
Definition Range.h:382
TRange(const BoundsType &InLowerBound, const BoundsType &InUpperBound)
Definition Range.h:92
static TArray< TRange > Union(const TRange &X, const TRange &Y)
Definition Range.h:604
static UE_FORCEINLINE_HINT TRange Exclusive(ElementValueOrConstRef Min, ElementValueOrConstRef Max)
Definition Range.h:684
static UE_FORCEINLINE_HINT TRange AtMost(ElementValueOrConstRef Value)
Definition Range.h:660
void SetUpperBoundValue(ElementValueOrConstRef NewUpperBoundValue)
Definition Range.h:296
void SetLowerBoundValue(ElementValueOrConstRef NewLowerBoundValue)
Definition Range.h:250
static TRange Intersection(const TRange &X, const TRange &Y)
Definition Range.h:555
TRangeBound< ElementType > BoundsType
Definition Range.h:53
friend uint32 GetTypeHash(const TRange &Range)
Definition Range.h:746
static TArray< TRange > Difference(const TRange &X, const TRange &Y)
Definition Range.h:469
bool IsEmpty() const
Definition Range.h:361
friend class FArchive & operator<<(class FArchive &Ar, TRange &Range)
Definition Range.h:735
static TRange Intersection(const TArray< TRange > &Ranges)
Definition Range.h:577
bool Contiguous(const TRange &Other) const
Definition Range.h:217
void SetLowerBound(const BoundsType &NewLowerBound)
Definition Range.h:239
TArray< TRange > Split(ElementValueOrConstRef Element) const
Definition Range.h:442
TRange(ElementValueOrConstRef A, ElementValueOrConstRef B)
Definition Range.h:81
bool operator!=(const TRange &Other) const
Definition Range.h:121
bool Adjoins(const TRange &Other) const
Definition Range.h:143
static TRange Hull(const TArray< TRange > &Ranges)
Definition Range.h:528
bool Contains(const TRange &Other) const
Definition Range.h:203
TRange(ElementValueOrConstRef A)
Definition Range.h:68
DifferenceType Size() const
Definition Range.h:427
void SetUpperBound(const BoundsType &NewUpperBound)
Definition Range.h:285
bool HasUpperBound() const
Definition Range.h:331
BoundsType GetUpperBound() const
Definition Range.h:274
ElementValueOrConstRef GetLowerBoundValue() const
Definition Range.h:263
ElementValueOrConstRef GetUpperBoundValue() const
Definition Range.h:309
bool operator==(const TRange &Other) const
Definition Range.h:105
BoundsType GetLowerBound() const
Definition Range.h:228
static UE_FORCEINLINE_HINT TRange GreaterThan(ElementValueOrConstRef Value)
Definition Range.h:696
bool Conjoins(const TRange &X, const TRange &Y) const
Definition Range.h:175
static UE_FORCEINLINE_HINT TRange Empty()
Definition Range.h:671
static UE_FORCEINLINE_HINT TRange LessThan(ElementValueOrConstRef Value)
Definition Range.h:721
bool IsDegenerate() const
Definition Range.h:345
static UE_FORCEINLINE_HINT TRange AtLeast(ElementValueOrConstRef Value)
Definition Range.h:648
static TRange Hull(const TRange &X, const TRange &Y)
Definition Range.h:506
static UE_FORCEINLINE_HINT TRange All()
Definition Range.h:636
TCallTraitsParamTypeHelper< T, PassByValue >::ParamType ParamType
Definition UnrealTypeTraits.h:275