Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
Range.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/Array.h"
7#include "Misc/AssertionMacros.h"
8#include "Misc/DateTime.h"
9#include "Math/RangeBound.h"
10#include "Misc/FrameNumber.h"
11#include "Serialization/Archive.h"
12
13
14/**
15 * Template for ranges.
16 *
17 * Note: This class is not intended for interval arithmetic (see TInterval for that).
18 *
19 * A range represents a contiguous set of elements that only stores the set's
20 * lower and upper bound values (aka. endpoints) for storage efficiency. Bound
21 * values may be exclusive (the value is not part of the range), inclusive (the
22 * value is part of the range) or open (there is no limit on the values).
23 *
24 * The template's primary focus is on continuous ranges, but it can be used for the
25 * representation of discrete ranges as well. The element type of discrete ranges
26 * has a well-defined stepping, such as an integer or a date, that separates the
27 * neighboring elements. This is in contrast with continuous ranges in which the
28 * step sizes, such as floats or time spans, are not of interest, and other elements
29 * may be found between any two elements (although, in practice, all ranges are
30 * discrete due to the limited precision of numerical values in computers).
31
32 * When working with ranges, the user of this template is responsible for correctly
33 * interpreting the range endpoints. Certain semantics will be different depending
34 * on whether the range is interpreted in a continuous or discrete domain.
35 *
36 * Iteration of a discrete range [A, B) includes the elements A to B-1. The elements
37 * of continuous ranges are generally not meant to be iterated. It is also important
38 * to consider the equivalence of different representations of discrete ranges. For
39 * example, the ranges [2, 6), (1, 5] and [2, 5] are equivalent in discrete domains,
40 * but different in continuous ones. In order to keep this class simple, we have not
41 * included canonicalization functions or auxiliary template parameters, such as
42 * unit and min/max domain elements. For ease of use in most common use cases, it is
43 * recommended to limit all operations to canonical ranges of the form [A, B) in
44 * which the lower bound is included and the upper bound is excluded from the range.
45 *
46 * @param ElementType The type of elements represented by the range
47 * @see RangeBound, TInterval
48 */
49template<typename ElementType> class TRange
50{
51public:
52
53 typedef TRangeBound<ElementType> BoundsType;
54
55 /*~ Typedef used to pass/return small element types by value rather than const& */
56 typedef typename TCallTraits<ElementType>::ParamType ElementValueOrConstRef;
57
58 /** Default constructor (no initialization). */
59 TRange() { }
60
61 /**
62 * Create a range with a single element.
63 *
64 * The created range is of the form [A, A].
65 *
66 * @param A The element in the range.
67 */
69 : LowerBound(BoundsType::Inclusive(A))
70 , UpperBound(BoundsType::Inclusive(A))
71 { }
72
73 /**
74 * Create and initializes a new range with the given lower and upper bounds.
75 *
76 * The created range is of the form [A, B).
77 *
78 * @param A The range's lower bound value (inclusive).
79 * @param B The range's upper bound value (exclusive).
80 */
82 : LowerBound(BoundsType::Inclusive(A))
83 , UpperBound(BoundsType::Exclusive(B))
84 { }
85
86 /**
87 * Create and initializes a new range with the given lower and upper bounds.
88 *
89 * @param InLowerBound The range's lower bound.
90 * @param InUpperBound The range's upper bound.
91 */
92 explicit TRange(const BoundsType& InLowerBound, const BoundsType& InUpperBound)
93 : LowerBound(InLowerBound)
94 , UpperBound(InUpperBound)
95 { }
96
97public:
98
99 /**
100 * Compare this range with the specified range for equality.
101 *
102 * @param Other The range to compare with.
103 * @return true if the ranges are equal, false otherwise.
104 */
105 bool operator==(const TRange& Other) const
106 {
107 if (IsEmpty() && Other.IsEmpty())
108 {
109 return true;
110 }
111
112 return ((LowerBound == Other.LowerBound) && (UpperBound == Other.UpperBound));
113 }
114
115 /**
116 * Compare this range with the specified range for inequality.
117 *
118 * @param Other The range to compare with.
119 * @return true if the ranges are not equal, false otherwise.
120 */
121 bool operator!=(const TRange& Other) const
122 {
123 if (IsEmpty() && Other.IsEmpty())
124 {
125 return false;
126 }
127
128 return ((LowerBound != Other.LowerBound) || (UpperBound != Other.UpperBound));
129 }
130
131public:
132
133 /**
134 * Check whether this range adjoins to another.
135 *
136 * Two ranges are adjoint if they are next to each other without overlapping, i.e.
137 * [A, B) and [B, C) or
138 * [A, B] and (B, C)
139 *
140 * @param Other The other range.
141 * @return true if this range adjoins the other, false otherwise.
142 */
143 bool Adjoins(const TRange& Other) const
144 {
145 if (IsEmpty() || Other.IsEmpty())
146 {
147 return false;
148 }
149
150 if (!UpperBound.IsOpen() && !Other.LowerBound.IsOpen() && UpperBound.GetValue() == Other.LowerBound.GetValue())
151 {
152 return ((UpperBound.IsInclusive() && Other.LowerBound.IsExclusive()) ||
153 (UpperBound.IsExclusive() && Other.LowerBound.IsInclusive()));
154 }
155
156 if (!Other.UpperBound.IsOpen() && !LowerBound.IsOpen() && Other.UpperBound.GetValue() == LowerBound.GetValue())
157 {
158 return ((Other.UpperBound.IsInclusive() && LowerBound.IsExclusive()) ||
159 (Other.UpperBound.IsExclusive() && LowerBound.IsInclusive()));
160 }
161
162 return false;
163 }
164
165 /**
166 * Check whether this range conjoins the two given ranges.
167 *
168 * A range conjoins two non-overlapping ranges if it adjoins both of them, i.e.
169 * [B, C) conjoins the two ranges [A, B) and [C, D).
170 *
171 * @param X The first range.
172 * @param Y The second range.
173 * @return true if this range conjoins the two ranges, false otherwise.
174 */
175 bool Conjoins(const TRange& X, const TRange& Y) const
176 {
177 if (X.Overlaps(Y))
178 {
179 return false;
180 }
181
182 return (Adjoins(X) && Adjoins(Y));
183 }
184
185 /**
186 * Check whether this range contains the specified element.
187 *
188 * @param Element The element to check.
189 * @return true if the range contains the element, false otherwise.
190 */
192 {
193 return ((BoundsType::MinLower(LowerBound, Element) == LowerBound) &&
194 (BoundsType::MaxUpper(UpperBound, Element) == UpperBound));
195 }
196
197 /**
198 * Check whether this range contains another range.
199 *
200 * @param Other The range to check.
201 * @return true if the range contains the other range, false otherwise.
202 */
203 bool Contains(const TRange& Other) const
204 {
205 return ((BoundsType::MinLower(LowerBound, Other.LowerBound) == LowerBound) &&
206 (BoundsType::MaxUpper(UpperBound, Other.UpperBound) == UpperBound));
207 }
208
209 /**
210 * Check if this range is contiguous with another range.
211 *
212 * Two ranges are contiguous if they are adjoint or overlapping.
213 *
214 * @param Other The other range.
215 * @return true if the ranges are contiguous, false otherwise.
216 */
217 bool Contiguous(const TRange& Other) const
218 {
219 return (Overlaps(Other) || Adjoins(Other));
220 }
221
222 /**
223 * Get the range's lower bound.
224 *
225 * @return Lower bound.
226 * @see GetLowerBoundValue, GetUpperBound, HasLowerBound
227 */
229 {
230 return LowerBound;
231 }
232
233 /**
234 * Assign the new lower bound for this range
235 *
236 * @param NewLowerBound The new lower bound to assign
237 * @see GetLowerBound
238 */
239 void SetLowerBound(const BoundsType& NewLowerBound)
240 {
241 LowerBound = NewLowerBound;
242 }
243
244 /**
245 * Assign the new lower bound value for this range. Current lower bound must not be open to call this method.
246 *
247 * @param NewLowerBoundValue The new lower bound value to assign
248 * @see GetLowerBound
249 */
251 {
252 LowerBound.SetValue(NewLowerBoundValue);
253 }
254
255 /**
256 * Get the value of the lower bound.
257 *
258 * Use HasLowerBound() to ensure that this range actually has a lower bound.
259 *
260 * @return Bound value.
261 * @see GetLowerBound, GetUpperBoundValue, HasLowerBound
262 */
264 {
265 return LowerBound.GetValue();
266 }
267
268 /**
269 * Get the range's upper bound.
270 *
271 * @return Upper bound.
272 * @see GetLowerBound, GetUpperBoundValue, HasUpperBound
273 */
275 {
276 return UpperBound;
277 }
278
279 /**
280 * Assign the new upper bound for this range
281 *
282 * @param NewUpperBound The new upper bound to assign
283 * @see GetUpperBound
284 */
285 void SetUpperBound(const BoundsType& NewUpperBound)
286 {
287 UpperBound = NewUpperBound;
288 }
289
290 /**
291 * Assign the new upper bound value for this range. Current upper bound must not be open to call this method.
292 *
293 * @param NewUpperBoundValue The new upper bound value to assign
294 * @see GetUpperBound
295 */
297 {
298 UpperBound.SetValue(NewUpperBoundValue);
299 }
300
301 /**
302 * Get the value of the upper bound.
303 *
304 * Use HasUpperBound() to ensure that this range actually has an upper bound.
305 *
306 * @return Bound value.
307 * @see GetLowerBoundValue, GetUpperBound, HasUpperBound
308 */
310 {
311 return UpperBound.GetValue();
312 }
313
314 /**
315 * Check whether the range has a lower bound.
316 *
317 * @return true if the range has a lower bound, false otherwise.
318 * @see GetLowerBound, GetLowerBoundValue, HasUpperBound
319 */
320 bool HasLowerBound() const
321 {
322 return LowerBound.IsClosed();
323 }
324
325 /**
326 * Check whether the range has an upper bound.
327 *
328 * @return true if the range has an upper bound, false otherwise.
329 * @see GetUpperBound, GetUpperBoundValue, HasLowerBound
330 */
331 bool HasUpperBound() const
332 {
333 return UpperBound.IsClosed();
334 }
335
336 /**
337 * Check whether this range is degenerate.
338 *
339 * A range is degenerate if it contains only a single element, i.e. has the following form:
340 * [A, A]
341 *
342 * @return true if the range is degenerate, false otherwise.
343 * @see IsEmpty
344 */
345 bool IsDegenerate() const
346 {
347 return (LowerBound.IsInclusive() && (LowerBound == UpperBound));
348 }
349
350 /**
351 * Check whether this range is empty.
352 *
353 * A range is empty if it contains no elements, i.e.
354 * (A, A)
355 * (A, A]
356 * [A, A)
357 *
358 * @return true if the range is empty, false otherwise.
359 * @see IsDegenerate
360 */
361 bool IsEmpty() const
362 {
363 if (LowerBound.IsClosed() && UpperBound.IsClosed())
364 {
365 if (LowerBound.GetValue() > UpperBound.GetValue())
366 {
367 return true;
368 }
369
370 return ((LowerBound.GetValue() == UpperBound.GetValue()) && (LowerBound.IsExclusive() || UpperBound.IsExclusive()));
371 }
372
373 return false;
374 }
375
376 /**
377 * Check whether this range overlaps with another.
378 *
379 * @param Other The other range.
380 * @return true if the ranges overlap, false otherwise.
381 */
382 bool Overlaps(const TRange& Other) const
383 {
384 if (IsEmpty() || Other.IsEmpty())
385 {
386 return false;
387 }
388
389 bool bUpperOpen = UpperBound.IsOpen() || Other.LowerBound.IsOpen();
390 bool bLowerOpen = LowerBound.IsOpen() || Other.UpperBound.IsOpen();
391
392 // true in the case that the bounds are open (default)
393 bool bUpperValid = true;
394 bool bLowerValid = true;
395
396 if (!bUpperOpen)
397 {
398 bool bUpperGreaterThan = UpperBound.GetValue() > Other.LowerBound.GetValue();
399 bool bUpperGreaterThanOrEqualTo = UpperBound.GetValue() >= Other.LowerBound.GetValue();
400 bool bUpperBothInclusive = UpperBound.IsInclusive() && Other.LowerBound.IsInclusive();
401
402 bUpperValid = bUpperBothInclusive ? bUpperGreaterThanOrEqualTo : bUpperGreaterThan;
403 }
404
405 if (!bLowerOpen)
406 {
407 bool bLowerLessThan = LowerBound.GetValue() < Other.UpperBound.GetValue();
408 bool bLowerLessThanOrEqualTo = LowerBound.GetValue() <= Other.UpperBound.GetValue();
409 bool bLowerBothInclusive = LowerBound.IsInclusive() && Other.UpperBound.IsInclusive();
410
411 bLowerValid = bLowerBothInclusive ? bLowerLessThanOrEqualTo : bLowerLessThan;
412 }
413
414 return bUpperValid && bLowerValid;
415 }
416
417 /**
418 * Compute the size (diameter, length, width) of this range.
419 *
420 * The size of a closed range is the difference between its upper and lower bound values.
421 * Use IsClosed() on the lower and upper bounds before calling this method in order to
422 * make sure that the range is closed.
423 *
424 * @return Range size.
425 */
426 template<typename DifferenceType> DifferenceType Size() const
427 {
428 check(LowerBound.IsClosed() && UpperBound.IsClosed());
429
430 return (UpperBound.GetValue() - LowerBound.GetValue());
431 }
432
433 /**
434 * Split the range into two ranges at the specified element.
435 *
436 * If a range [A, C) does not contain the element X, the original range is returned.
437 * Otherwise the range is split into two ranges [A, X) and [X, C), each of which may be empty.
438 *
439 * @param Element The element at which to split the range.
440 */
442 {
443 TArray<TRange> Result;
444
445 if (Contains(Element))
446 {
447 Result.Add(TRange(LowerBound, BoundsType::Exclusive(Element)));
448 Result.Add(TRange(BoundsType::Inclusive(Element), UpperBound));
449 }
450 else
451 {
452 Result.Add(*this);
453 }
454
455 return Result;
456 }
457
458public:
459
460 /**
461 * Calculate the difference between two ranges, i.e. X - Y.
462 *
463 * @param X The first range to subtract from.
464 * @param Y The second range to subtract with.
465 * @return Between 0 and 2 remaining ranges.
466 * @see Hull, Intersection, Union
467 */
469 {
470 TArray<TRange> Result;
471
472 if (X.Overlaps(Y))
473 {
474 TRange LowerRange = TRange(X.LowerBound, BoundsType::FlipInclusion(Y.LowerBound));
475 TRange UpperRange = TRange(BoundsType::FlipInclusion(Y.UpperBound), X.UpperBound);
476
477 if (!LowerRange.IsEmpty())
478 {
479 Result.Add(LowerRange);
480 }
481
482 if (!UpperRange.IsEmpty())
483 {
484 Result.Add(UpperRange);
485 }
486 }
487 else
488 {
489 Result.Add(X);
490 }
491
492 return Result;
493 }
494
495 /**
496 * Compute the hull of two ranges.
497 *
498 * The hull is the smallest range that contains both ranges.
499 *
500 * @param X The first range.
501 * @param Y The second range.
502 * @return The hull.
503 * @see Difference, Intersection, Union
504 */
505 static FORCEINLINE TRange Hull(const TRange& X, const TRange& Y)
506 {
507 if (X.IsEmpty())
508 {
509 return Y;
510 }
511
512 if (Y.IsEmpty())
513 {
514 return X;
515 }
516
517 return TRange(BoundsType::MinLower(X.LowerBound, Y.LowerBound), BoundsType::MaxUpper(X.UpperBound, Y.UpperBound));
518 }
519
520 /**
521 * Compute the hull of many ranges.
522 *
523 * @param Ranges The ranges to hull.
524 * @return The hull.
525 * @see Difference, Intersection, Union
526 */
527 static FORCEINLINE TRange Hull(const TArray<TRange>& Ranges)
528 {
529 if (Ranges.Num() == 0)
530 {
531 return TRange::Empty();
532 }
533
534 TRange Bounds = Ranges[0];
535
536 for (int32 i = 1; i < Ranges.Num(); ++i)
537 {
538 Bounds = Hull(Bounds, Ranges[i]);
539 }
540
541 return Bounds;
542 }
543
544 /**
545 * Compute the intersection of two ranges.
546 *
547 * The intersection of two ranges is the largest range that is contained by both ranges.
548 *
549 * @param X The first range.
550 * @param Y The second range.
551 * @return The intersection, or an empty range if the ranges do not overlap.
552 * @see Difference, Hull, Union
553 */
554 static FORCEINLINE TRange Intersection(const TRange& X, const TRange& Y)
555 {
556 if (X.IsEmpty())
557 {
558 return TRange::Empty();
559 }
560
561 if (Y.IsEmpty())
562 {
563 return TRange::Empty();
564 }
565
566 return TRange(BoundsType::MaxLower(X.LowerBound, Y.LowerBound), BoundsType::MinUpper(X.UpperBound, Y.UpperBound));
567 }
568
569 /**
570 * Compute the intersection of many ranges.
571 *
572 * @param Ranges The ranges to intersect.
573 * @return The intersection.
574 * @see Difference, Hull, Union
575 */
576 static FORCEINLINE TRange Intersection(const TArray<TRange>& Ranges)
577 {
578 if (Ranges.Num() == 0)
579 {
580 return TRange::Empty();
581 }
582
583 TRange Bounds = Ranges[0];
584
585 for (int32 i = 1; i < Ranges.Num(); ++i)
586 {
587 Bounds = Intersection(Bounds, Ranges[i]);
588 }
589
590 return Bounds;
591 }
592
593 /**
594 * Return the union of two contiguous ranges.
595 *
596 * A union is a range or series of ranges that contains both ranges.
597 *
598 * @param X The first range.
599 * @param Y The second range.
600 * @return The union, or both ranges if the two ranges are not contiguous, or no ranges if both ranges are empty.
601 * @see Difference, Hull, Intersection
602 */
603 static FORCEINLINE TArray<TRange> Union(const TRange& X, const TRange& Y)
604 {
605 TArray<TRange> OutRanges;
606
607 if (X.Contiguous(Y))
608 {
609 OutRanges.Add(TRange(BoundsType::MinLower(X.LowerBound, Y.LowerBound), BoundsType::MaxUpper(X.UpperBound, Y.UpperBound)));
610 }
611 else
612 {
613 if (!X.IsEmpty())
614 {
615 OutRanges.Add(X);
616 }
617
618 if (!Y.IsEmpty())
619 {
620 OutRanges.Add(Y);
621 }
622 }
623
624 return OutRanges;
625 }
626
627public:
628
629 /**
630 * Create an unbounded (open) range that contains all elements of the domain.
631 *
632 * @return A new range.
633 * @see AtLeast, AtMost, Empty, Exclusive, GreaterThan, Inclusive, LessThan
634 */
635 static FORCEINLINE TRange All()
636 {
637 return TRange(BoundsType::Open(), BoundsType::Open());
638 }
639
640 /**
641 * Create a left-bounded range that contains all elements greater than or equal to the specified value.
642 *
643 * @param Value The value.
644 * @return A new range.
645 * @see All, AtMost, Empty, Exclusive, GreaterThan, Inclusive, LessThan
646 */
648 {
649 return TRange(BoundsType::Inclusive(Value), BoundsType::Open());
650 }
651
652 /**
653 * Create a right-bounded range that contains all elements less than or equal to the specified value.
654 *
655 * @param Value The value.
656 * @return A new range.
657 * @see All, AtLeast, Empty, Exclusive, GreaterThan, Inclusive, LessThan
658 */
660 {
661 return TRange(BoundsType::Open(), BoundsType::Inclusive(Value));
662 }
663
664 /**
665 * Return an empty range.
666 *
667 * @return Empty range.
668 * @see All, AtLeast, AtMost, Exclusive, GreaterThan, Inclusive, LessThan
669 */
670 static FORCEINLINE TRange Empty()
671 {
672 return TRange(BoundsType::Exclusive(ElementType()), BoundsType::Exclusive(ElementType()));
673 }
674
675 /**
676 * Create a range that excludes the given minimum and maximum values.
677 *
678 * @param MinThe minimum value to be included.
679 * @param Max The maximum value to be included.
680 * @return A new range.
681 * @see All, AtLeast, AtMost, Empty, Exclusive, GreaterThan, Inclusive, LessThan
682 */
684 {
685 return TRange(BoundsType::Exclusive(Min), BoundsType::Exclusive(Max));
686 }
687
688 /**
689 * Create a left-bounded range that contains all elements greater than the specified value.
690 *
691 * @param Value The value.
692 * @return A new range.
693 * @see All, AtLeast, AtMost, Empty, Exclusive, Inclusive, LessThan
694 */
696 {
697 return TRange(BoundsType::Exclusive(Value), BoundsType::Open());
698 }
699
700 /**
701 * Create a range that includes the given minimum and maximum values.
702 *
703 * @param Min The minimum value to be included.
704 * @param Max The maximum value to be included.
705 * @return A new range.
706 * @see All, AtLeast, AtMost, Empty, Exclusive, GreaterThan, LessThan
707 */
709 {
710 return TRange(BoundsType::Inclusive(Min), BoundsType::Inclusive(Max));
711 }
712
713 /**
714 * Create a right-bounded range that contains all elements less than the specified value.
715 *
716 * @param Value The value.
717 * @return A new range.
718 * @see All, AtLeast, AtMost, Empty, Exclusive, GreaterThan, Inclusive
719 */
721 {
722 return TRange(BoundsType::Open(), BoundsType::Exclusive(Value));
723 }
724
725public:
726
727 /**
728 * Serializes the given range from or into the specified archive.
729 *
730 * @param Ar The archive to serialize from or into.
731 * @param Range The range to serialize.
732 * @return The archive.
733 */
734 friend class FArchive& operator<<(class FArchive& Ar, TRange& Range)
735 {
736 return Ar << Range.LowerBound << Range.UpperBound;
737 }
738
739 /**
740 * Gets the hash for the specified range.
741 *
742 * @param Range The range to get the hash for.
743 * @return Hash value.
744 */
745 friend uint32 GetTypeHash(const TRange& Range)
746 {
747 return (GetTypeHash(Range.LowerBound) + 23 * GetTypeHash(Range.UpperBound));
748 }
749
750private:
751
752 /** Holds the range's lower bound. */
754
755 /** Holds the range's upper bound. */
757};
758
759
760/* Default ranges for built-in types
761 *****************************************************************************/
762
763#define DEFINE_RANGE_WRAPPER_STRUCT(Name, ElementType)
764 struct Name : TRange<ElementType>
765 {
766 private:
767 typedef TRange<ElementType> Super;
768
769 public:
770 Name()
771 : Super()
772 {
773 }
774
775 Name(const Super& Rhs)
776 : Super(Rhs)
777 {
778 }
779
780 explicit Name(ElementValueOrConstRef A)
781 : Super(A)
782 {
783 }
784
785 explicit Name(ElementValueOrConstRef A, ElementValueOrConstRef B)
786 : Super(A, B)
787 {
788 }
789
790 explicit Name(const TRangeBound<ElementType>& InLowerBound, const TRangeBound<ElementType>& InUpperBound)
791 : Super(InLowerBound, InUpperBound)
792 {
793 }
794
795 TArray<Name> Split(ElementValueOrConstRef Element) const
796 {
797 return TArray<Name>(Super::Split(Element));
798 }
799
800 static FORCEINLINE TArray<Name> Difference(const Name& X, const Name& Y)
801 {
802 return TArray<Name>(Super::Difference(X, Y));
803 }
804
805 static FORCEINLINE Name Empty()
806 {
807 return Super::Empty();
808 }
809
810 static FORCEINLINE Name Hull(const Name& X, const Name& Y)
811 {
812 return Super::Hull(X, Y);
813 }
814
815 static FORCEINLINE Name Hull(const TArray<Name>& Ranges)
816 {
817 return Super::Hull(reinterpret_cast<const TArray<Super>&>(Ranges));
818 }
819
820 static FORCEINLINE Name Intersection(const Name& X, const Name& Y)
821 {
822 return Super::Intersection(X, Y);
823 }
824
825 static FORCEINLINE Name Intersection(const TArray<Name>& Ranges)
826 {
827 return Super::Intersection(reinterpret_cast<const TArray<Super>&>(Ranges));
828 }
829
830 static FORCEINLINE TArray<Name> Union(const Name& X, const Name& Y)
831 {
832 return TArray<Name>(Super::Union(X, Y));
833 }
834
835 static FORCEINLINE Name All()
836 {
837 return Super::All();
838 }
839
840 static FORCEINLINE Name AtLeast(ElementValueOrConstRef Value)
841 {
842 return Super::AtLeast(Value);
843 }
844
845 static FORCEINLINE Name AtMost(ElementValueOrConstRef Value)
846 {
847 return Super::AtMost(Value);
848 }
849
850 static FORCEINLINE TRange GreaterThan(ElementValueOrConstRef Value)
851 {
852 return Super::GreaterThan(Value);
853 }
854
855 static FORCEINLINE TRange LessThan(ElementValueOrConstRef Value)
856 {
857 return Super::LessThan(Value);
858 }
859 };
860
861 template <>
862 struct TIsBitwiseConstructible<Name, TRange<ElementType>>
863 {
864 enum { Value = true };
865 };
866
867 template <>
868 struct TIsBitwiseConstructible<TRange<ElementType>, Name>
869 {
870 enum { Value = true };
871 };
872
874DEFINE_RANGE_WRAPPER_STRUCT(FDoubleRange, double)
875DEFINE_RANGE_WRAPPER_STRUCT(FFloatRange, float)
876DEFINE_RANGE_WRAPPER_STRUCT(FInt8Range, int8)
877DEFINE_RANGE_WRAPPER_STRUCT(FInt16Range, int16)
878DEFINE_RANGE_WRAPPER_STRUCT(FInt32Range, int32)
879DEFINE_RANGE_WRAPPER_STRUCT(FInt64Range, int64)
#define check(expr)
#define FORCEINLINE
Definition Platform.h:644
#define DEFINE_RANGE_WRAPPER_STRUCT(Name, ElementType)
Definition Range.h:763
TCallTraits< ElementType >::ParamType ElementValueOrConstRef
Definition Range.h:56
static FORCEINLINE TRange Intersection(const TArray< TRange > &Ranges)
Definition Range.h:576
BoundsType LowerBound
Definition Range.h:753
bool Contains(ElementValueOrConstRef Element) const
Definition Range.h:191
TRange()
Definition Range.h:59
bool HasLowerBound() const
Definition Range.h:320
bool Overlaps(const TRange &Other) const
Definition Range.h:382
static FORCEINLINE TRange Hull(const TRange &X, const TRange &Y)
Definition Range.h:505
TRange(const BoundsType &InLowerBound, const BoundsType &InUpperBound)
Definition Range.h:92
static FORCEINLINE TRange LessThan(ElementValueOrConstRef Value)
Definition Range.h:720
static FORCEINLINE TRange AtLeast(ElementValueOrConstRef Value)
Definition Range.h:647
static FORCEINLINE TRange GreaterThan(ElementValueOrConstRef Value)
Definition Range.h:695
static FORCEINLINE TRange AtMost(ElementValueOrConstRef Value)
Definition Range.h:659
void SetUpperBoundValue(ElementValueOrConstRef NewUpperBoundValue)
Definition Range.h:296
void SetLowerBoundValue(ElementValueOrConstRef NewLowerBoundValue)
Definition Range.h:250
TRangeBound< ElementType > BoundsType
Definition Range.h:53
static FORCEINLINE TArray< TRange > Union(const TRange &X, const TRange &Y)
Definition Range.h:603
friend uint32 GetTypeHash(const TRange &Range)
Definition Range.h:745
bool IsEmpty() const
Definition Range.h:361
static FORCEINLINE TRange All()
Definition Range.h:635
bool Contiguous(const TRange &Other) const
Definition Range.h:217
static FORCEINLINE TRange Hull(const TArray< TRange > &Ranges)
Definition Range.h:527
void SetLowerBound(const BoundsType &NewLowerBound)
Definition Range.h:239
TArray< TRange > Split(ElementValueOrConstRef Element) const
Definition Range.h:441
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
bool Contains(const TRange &Other) const
Definition Range.h:203
TRange(ElementValueOrConstRef A)
Definition Range.h:68
DifferenceType Size() const
Definition Range.h:426
static FORCEINLINE TRange Intersection(const TRange &X, const TRange &Y)
Definition Range.h:554
void SetUpperBound(const BoundsType &NewUpperBound)
Definition Range.h:285
BoundsType UpperBound
Definition Range.h:756
bool HasUpperBound() const
Definition Range.h:331
BoundsType GetUpperBound() const
Definition Range.h:274
ElementValueOrConstRef GetLowerBoundValue() const
Definition Range.h:263
static FORCEINLINE TRange Exclusive(ElementValueOrConstRef Min, ElementValueOrConstRef Max)
Definition Range.h:683
ElementValueOrConstRef GetUpperBoundValue() const
Definition Range.h:309
bool operator==(const TRange &Other) const
Definition Range.h:105
static FORCEINLINE TRange Inclusive(ElementValueOrConstRef Min, ElementValueOrConstRef Max)
Definition Range.h:708
BoundsType GetLowerBound() const
Definition Range.h:228
bool Conjoins(const TRange &X, const TRange &Y) const
Definition Range.h:175
static FORCEINLINE TRange Empty()
Definition Range.h:670
bool IsDegenerate() const
Definition Range.h:345
static FORCEINLINE TArray< TRange > Difference(const TRange &X, const TRange &Y)
Definition Range.h:468