![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <Range.h>
Public Types | |
| typedef TRangeBound< ElementType > | BoundsType |
| typedef TCallTraits< ElementType >::ParamType | ElementValueOrConstRef |
Static Public Member Functions | |
| static TArray< TRange > | Difference (const TRange &X, const TRange &Y) |
| static TRange | Hull (const TRange &X, const TRange &Y) |
| static TRange | Hull (const TArray< TRange > &Ranges) |
| static TRange | Intersection (const TRange &X, const TRange &Y) |
| static TRange | Intersection (const TArray< TRange > &Ranges) |
| static TArray< TRange > | Union (const TRange &X, const TRange &Y) |
| static UE_FORCEINLINE_HINT TRange | All () |
| static UE_FORCEINLINE_HINT TRange | AtLeast (ElementValueOrConstRef Value) |
| static UE_FORCEINLINE_HINT TRange | AtMost (ElementValueOrConstRef Value) |
| static UE_FORCEINLINE_HINT TRange | Empty () |
| static UE_FORCEINLINE_HINT TRange | Exclusive (ElementValueOrConstRef Min, ElementValueOrConstRef Max) |
| static UE_FORCEINLINE_HINT TRange | GreaterThan (ElementValueOrConstRef Value) |
| static UE_FORCEINLINE_HINT TRange | Inclusive (ElementValueOrConstRef Min, ElementValueOrConstRef Max) |
| static UE_FORCEINLINE_HINT TRange | LessThan (ElementValueOrConstRef Value) |
Friends | |
| class FArchive & | operator<< (class FArchive &Ar, TRange &Range) |
| uint32 | GetTypeHash (const TRange &Range) |
Template for ranges.
Note: This class is not intended for interval arithmetic (see TInterval for that).
A range represents a contiguous set of elements that only stores the set's lower and upper bound values (aka. endpoints) for storage efficiency. Bound values may be exclusive (the value is not part of the range), inclusive (the value is part of the range) or open (there is no limit on the values).
The template's primary focus is on continuous ranges, but it can be used for the representation of discrete ranges as well. The element type of discrete ranges has a well-defined stepping, such as an integer or a date, that separates the neighboring elements. This is in contrast with continuous ranges in which the step sizes, such as floats or time spans, are not of interest, and other elements may be found between any two elements (although, in practice, all ranges are discrete due to the limited precision of numerical values in computers).
When working with ranges, the user of this template is responsible for correctly interpreting the range endpoints. Certain semantics will be different depending on whether the range is interpreted in a continuous or discrete domain.
Iteration of a discrete range [A, B) includes the elements A to B-1. The elements of continuous ranges are generally not meant to be iterated. It is also important to consider the equivalence of different representations of discrete ranges. For example, the ranges [2, 6), (1, 5] and [2, 5] are equivalent in discrete domains, but different in continuous ones. In order to keep this class simple, we have not included canonicalization functions or auxiliary template parameters, such as unit and min/max domain elements. For ease of use in most common use cases, it is recommended to limit all operations to canonical ranges of the form [A, B) in which the lower bound is included and the upper bound is excluded from the range.
| ElementType | The type of elements represented by the range |
| typedef TRangeBound<ElementType> TRange< ElementType >::BoundsType |
| typedef TCallTraits<ElementType>::ParamType TRange< ElementType >::ElementValueOrConstRef |
Default constructor (no initialization).
|
inlineexplicit |
Create a range with a single element.
The created range is of the form [A, A].
| A | The element in the range. |
|
inlineexplicit |
Create and initializes a new range with the given lower and upper bounds.
The created range is of the form [A, B).
| A | The range's lower bound value (inclusive). |
| B | The range's upper bound value (exclusive). |
|
inlineexplicit |
Create and initializes a new range with the given lower and upper bounds.
| InLowerBound | The range's lower bound. |
| InUpperBound | The range's upper bound. |
|
inline |
Check whether this range adjoins to another.
Two ranges are adjoint if they are next to each other without overlapping, i.e. [A, B) and [B, C) or [A, B] and (B, C)
| Other | The other range. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
Check whether this range conjoins the two given ranges.
A range conjoins two non-overlapping ranges if it adjoins both of them, i.e. [B, C) conjoins the two ranges [A, B) and [C, D).
| X | The first range. |
| Y | The second range. |
|
inline |
Check whether this range contains another range.
| Other | The range to check. |
|
inline |
Check whether this range contains the specified element.
| Element | The element to check. |
|
inline |
Check if this range is contiguous with another range.
Two ranges are contiguous if they are adjoint or overlapping.
| Other | The other range. |
|
inlinestatic |
Calculate the difference between two ranges, i.e. X - Y.
| X | The first range to subtract from. |
| Y | The second range to subtract with. |
|
inlinestatic |
|
inlinestatic |
|
inline |
Get the range's lower bound.
|
inline |
Get the value of the lower bound.
Use HasLowerBound() to ensure that this range actually has a lower bound.
|
inline |
Get the range's upper bound.
|
inline |
Get the value of the upper bound.
Use HasUpperBound() to ensure that this range actually has an upper bound.
|
inlinestatic |
Check whether the range has a lower bound.
Check whether the range has an upper bound.
|
inlinestatic |
Compute the hull of many ranges.
| Ranges | The ranges to hull. |
|
inlinestatic |
Compute the hull of two ranges.
The hull is the smallest range that contains both ranges.
| X | The first range. |
| Y | The second range. |
|
inlinestatic |
|
inlinestatic |
Compute the intersection of many ranges.
| Ranges | The ranges to intersect. |
|
inlinestatic |
Compute the intersection of two ranges.
The intersection of two ranges is the largest range that is contained by both ranges.
| X | The first range. |
| Y | The second range. |
Check whether this range is degenerate.
A range is degenerate if it contains only a single element, i.e. has the following form: [A, A]
Check whether this range is empty.
A range is empty if it contains no elements, i.e. (A, A) (A, A] [A, A)
|
inlinestatic |
|
inline |
Compare this range with the specified range for inequality.
| Other | The range to compare with. |
|
inline |
Compare this range with the specified range for equality.
| Other | The range to compare with. |
|
inline |
Check whether this range overlaps with another.
| Other | The other range. |
|
inline |
Assign the new lower bound for this range
| NewLowerBound | The new lower bound to assign |
|
inline |
Assign the new lower bound value for this range. Current lower bound must not be open to call this method.
| NewLowerBoundValue | The new lower bound value to assign |
|
inline |
Assign the new upper bound for this range
| NewUpperBound | The new upper bound to assign |
|
inline |
Assign the new upper bound value for this range. Current upper bound must not be open to call this method.
| NewUpperBoundValue | The new upper bound value to assign |
|
inline |
Compute the size (diameter, length, width) of this range.
The size of a closed range is the difference between its upper and lower bound values. Use IsClosed() on the lower and upper bounds before calling this method in order to make sure that the range is closed.
|
inline |
Split the range into two ranges at the specified element.
If a range [A, C) does not contain the element X, the original range is returned. Otherwise the range is split into two ranges [A, X) and [X, C), each of which may be empty.
| Element | The element at which to split the range. |
|
inlinestatic |
Return the union of two contiguous ranges.
A union is a range or series of ranges that contains both ranges.
| X | The first range. |
| Y | The second range. |
Gets the hash for the specified range.
| Range | The range to get the hash for. |
|
friend |
Serializes the given range from or into the specified archive.
| Ar | The archive to serialize from or into. |
| Range | The range to serialize. |