engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | 友元 | 所有成员列表
TRange< ElementType > 模板类 参考

Template for ranges. 更多...

#include <Range.h>

Public 成员函数

bool Adjoins (const TRange &Other) const
 Check whether this range adjoins to another. 更多...
 
bool Conjoins (const TRange &X, const TRange &Y) const
 Check whether this range conjoins the two given ranges. 更多...
 
bool Contains (const TRange &Other) const
 Check whether this range contains another range. 更多...
 
bool Contains (ElementValueOrConstRef Element) const
 Check whether this range contains the specified element. 更多...
 
bool Contiguous (const TRange &Other) const
 Check if this range is contiguous with another range. 更多...
 
BoundsType GetLowerBound () const
 Get the range's lower bound. 更多...
 
ElementValueOrConstRef GetLowerBoundValue () const
 Get the value of the lower bound. 更多...
 
BoundsType GetUpperBound () const
 Get the range's upper bound. 更多...
 
ElementValueOrConstRef GetUpperBoundValue () const
 Get the value of the upper bound. 更多...
 
bool HasLowerBound () const
 Check whether the range has a lower bound. 更多...
 
bool HasUpperBound () const
 Check whether the range has an upper bound. 更多...
 
bool IsDegenerate () const
 Check whether this range is degenerate. 更多...
 
bool IsEmpty () const
 Check whether this range is empty. 更多...
 
bool operator!= (const TRange &Other) const
 Compare this range with the specified range for inequality. 更多...
 
bool operator== (const TRange &Other) const
 Compare this range with the specified range for equality. 更多...
 
bool Overlaps (const TRange &Other) const
 Check whether this range overlaps with another. 更多...
 
void SetLowerBound (const BoundsType &NewLowerBound)
 Assign the new lower bound for this range 更多...
 
void SetLowerBoundValue (ElementValueOrConstRef NewLowerBoundValue)
 Assign the new lower bound value for this range. 更多...
 
void SetUpperBound (const BoundsType &NewUpperBound)
 Assign the new upper bound for this range 更多...
 
void SetUpperBoundValue (ElementValueOrConstRef NewUpperBoundValue)
 Assign the new upper bound value for this range. 更多...
 
template<typename DifferenceType >
DifferenceType Size () const
 Compute the size (diameter, length, width) of this range. 更多...
 
TArray< TRange > Split (ElementValueOrConstRef Element) const
 Split the range into two ranges at the specified element. 更多...
 
 TRange ()
 Default constructor (no initialization).
 
 TRange (const BoundsType &InLowerBound, const BoundsType &InUpperBound)
 Create and initializes a new range with the given lower and upper bounds. 更多...
 
 TRange (ElementValueOrConstRef A)
 Create a range with a single element. 更多...
 
 TRange (ElementValueOrConstRef A, ElementValueOrConstRef B)
 Create and initializes a new range with the given lower and upper bounds. 更多...
 

静态 Public 成员函数

static FORCEINLINE TRange All ()
 Create an unbounded (open) range that contains all elements of the domain. 更多...
 
static FORCEINLINE TRange AtLeast (ElementValueOrConstRef Value)
 Create a left-bounded range that contains all elements greater than or equal to the specified value. 更多...
 
static FORCEINLINE TRange AtMost (ElementValueOrConstRef Value)
 Create a right-bounded range that contains all elements less than or equal to the specified value. 更多...
 
static FORCEINLINE TArray< TRange > Difference (const TRange &X, const TRange &Y)
 Calculate the difference between two ranges, i.e. 更多...
 
static FORCEINLINE TRange Empty ()
 Return an empty range. 更多...
 
static FORCEINLINE TRange Exclusive (ElementValueOrConstRef Min, ElementValueOrConstRef Max)
 Create a range that excludes the given minimum and maximum values. 更多...
 
static FORCEINLINE TRange GreaterThan (ElementValueOrConstRef Value)
 Create a left-bounded range that contains all elements greater than the specified value. 更多...
 
static FORCEINLINE TRange Hull (const TArray< TRange > &Ranges)
 Compute the hull of many ranges. 更多...
 
static FORCEINLINE TRange Hull (const TRange &X, const TRange &Y)
 Compute the hull of two ranges. 更多...
 
static FORCEINLINE TRange Inclusive (ElementValueOrConstRef Min, ElementValueOrConstRef Max)
 Create a range that includes the given minimum and maximum values. 更多...
 
static FORCEINLINE TRange Intersection (const TArray< TRange > &Ranges)
 Compute the intersection of many ranges. 更多...
 
static FORCEINLINE TRange Intersection (const TRange &X, const TRange &Y)
 Compute the intersection of two ranges. 更多...
 
static FORCEINLINE TRange LessThan (ElementValueOrConstRef Value)
 Create a right-bounded range that contains all elements less than the specified value. 更多...
 
static FORCEINLINE TArray< TRange > Union (const TRange &X, const TRange &Y)
 Return the union of two contiguous ranges. 更多...
 

友元

uint32 GetTypeHash (const TRange &Range)
 Gets the hash for the specified range. 更多...
 
class FArchive & operator<< (class FArchive &Ar, TRange &Range)
 Serializes the given range from or into the specified archive. 更多...
 

详细描述

template<typename ElementType>
class TRange< ElementType >

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.

参数
ElementTypeThe type of elements represented by the range
参见
RangeBound, TInterval

构造及析构函数说明

◆ TRange() [1/3]

template<typename ElementType >
TRange< ElementType >::TRange ( ElementValueOrConstRef  A)
inlineexplicit

Create a range with a single element.

The created range is of the form [A, A].

参数
AThe element in the range.

◆ TRange() [2/3]

template<typename ElementType >
TRange< ElementType >::TRange ( ElementValueOrConstRef  A,
ElementValueOrConstRef  B 
)
inlineexplicit

Create and initializes a new range with the given lower and upper bounds.

The created range is of the form [A, B).

参数
AThe range's lower bound value (inclusive).
BThe range's upper bound value (exclusive).

◆ TRange() [3/3]

template<typename ElementType >
TRange< ElementType >::TRange ( const BoundsType &  InLowerBound,
const BoundsType &  InUpperBound 
)
inlineexplicit

Create and initializes a new range with the given lower and upper bounds.

参数
InLowerBoundThe range's lower bound.
InUpperBoundThe range's upper bound.

成员函数说明

◆ Adjoins()

template<typename ElementType >
bool TRange< ElementType >::Adjoins ( const TRange< ElementType > &  Other) const
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)

参数
OtherThe other range.
返回
true if this range adjoins the other, false otherwise.

◆ All()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::All ( )
inlinestatic

Create an unbounded (open) range that contains all elements of the domain.

返回
A new range.
参见
AtLeast, AtMost, Empty, Exclusive, GreaterThan, Inclusive, LessThan

◆ AtLeast()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::AtLeast ( ElementValueOrConstRef  Value)
inlinestatic

Create a left-bounded range that contains all elements greater than or equal to the specified value.

参数
ValueThe value.
返回
A new range.
参见
All, AtMost, Empty, Exclusive, GreaterThan, Inclusive, LessThan

◆ AtMost()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::AtMost ( ElementValueOrConstRef  Value)
inlinestatic

Create a right-bounded range that contains all elements less than or equal to the specified value.

参数
ValueThe value.
返回
A new range.
参见
All, AtLeast, Empty, Exclusive, GreaterThan, Inclusive, LessThan

◆ Conjoins()

template<typename ElementType >
bool TRange< ElementType >::Conjoins ( const TRange< ElementType > &  X,
const TRange< ElementType > &  Y 
) const
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).

参数
XThe first range.
YThe second range.
返回
true if this range conjoins the two ranges, false otherwise.

◆ Contains() [1/2]

template<typename ElementType >
bool TRange< ElementType >::Contains ( const TRange< ElementType > &  Other) const
inline

Check whether this range contains another range.

参数
OtherThe range to check.
返回
true if the range contains the other range, false otherwise.

◆ Contains() [2/2]

template<typename ElementType >
bool TRange< ElementType >::Contains ( ElementValueOrConstRef  Element) const
inline

Check whether this range contains the specified element.

参数
ElementThe element to check.
返回
true if the range contains the element, false otherwise.

◆ Contiguous()

template<typename ElementType >
bool TRange< ElementType >::Contiguous ( const TRange< ElementType > &  Other) const
inline

Check if this range is contiguous with another range.

Two ranges are contiguous if they are adjoint or overlapping.

参数
OtherThe other range.
返回
true if the ranges are contiguous, false otherwise.

◆ Difference()

template<typename ElementType >
static FORCEINLINE TArray< TRange > TRange< ElementType >::Difference ( const TRange< ElementType > &  X,
const TRange< ElementType > &  Y 
)
inlinestatic

Calculate the difference between two ranges, i.e.

X - Y.

参数
XThe first range to subtract from.
YThe second range to subtract with.
返回
Between 0 and 2 remaining ranges.
参见
Hull, Intersection, Union

◆ Empty()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Empty ( )
inlinestatic

Return an empty range.

返回
Empty range.
参见
All, AtLeast, AtMost, Exclusive, GreaterThan, Inclusive, LessThan

◆ Exclusive()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Exclusive ( ElementValueOrConstRef  Min,
ElementValueOrConstRef  Max 
)
inlinestatic

Create a range that excludes the given minimum and maximum values.

参数
MinTheminimum value to be included.
MaxThe maximum value to be included.
返回
A new range.
参见
All, AtLeast, AtMost, Empty, Exclusive, GreaterThan, Inclusive, LessThan

◆ GetLowerBound()

template<typename ElementType >
BoundsType TRange< ElementType >::GetLowerBound ( ) const
inline

Get the range's lower bound.

返回
Lower bound.
参见
GetLowerBoundValue, GetUpperBound, HasLowerBound

◆ GetLowerBoundValue()

template<typename ElementType >
ElementValueOrConstRef TRange< ElementType >::GetLowerBoundValue ( ) const
inline

Get the value of the lower bound.

Use HasLowerBound() to ensure that this range actually has a lower bound.

返回
Bound value.
参见
GetLowerBound, GetUpperBoundValue, HasLowerBound

◆ GetUpperBound()

template<typename ElementType >
BoundsType TRange< ElementType >::GetUpperBound ( ) const
inline

Get the range's upper bound.

返回
Upper bound.
参见
GetLowerBound, GetUpperBoundValue, HasUpperBound

◆ GetUpperBoundValue()

template<typename ElementType >
ElementValueOrConstRef TRange< ElementType >::GetUpperBoundValue ( ) const
inline

Get the value of the upper bound.

Use HasUpperBound() to ensure that this range actually has an upper bound.

返回
Bound value.
参见
GetLowerBoundValue, GetUpperBound, HasUpperBound

◆ GreaterThan()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::GreaterThan ( ElementValueOrConstRef  Value)
inlinestatic

Create a left-bounded range that contains all elements greater than the specified value.

参数
ValueThe value.
返回
A new range.
参见
All, AtLeast, AtMost, Empty, Exclusive, Inclusive, LessThan

◆ HasLowerBound()

template<typename ElementType >
bool TRange< ElementType >::HasLowerBound ( ) const
inline

Check whether the range has a lower bound.

返回
true if the range has a lower bound, false otherwise.
参见
GetLowerBound, GetLowerBoundValue, HasUpperBound

◆ HasUpperBound()

template<typename ElementType >
bool TRange< ElementType >::HasUpperBound ( ) const
inline

Check whether the range has an upper bound.

返回
true if the range has an upper bound, false otherwise.
参见
GetUpperBound, GetUpperBoundValue, HasLowerBound

◆ Hull() [1/2]

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Hull ( const TArray< TRange< ElementType > > &  Ranges)
inlinestatic

Compute the hull of many ranges.

参数
RangesThe ranges to hull.
返回
The hull.
参见
Difference, Intersection, Union

◆ Hull() [2/2]

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Hull ( const TRange< ElementType > &  X,
const TRange< ElementType > &  Y 
)
inlinestatic

Compute the hull of two ranges.

The hull is the smallest range that contains both ranges.

参数
XThe first range.
YThe second range.
返回
The hull.
参见
Difference, Intersection, Union

◆ Inclusive()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Inclusive ( ElementValueOrConstRef  Min,
ElementValueOrConstRef  Max 
)
inlinestatic

Create a range that includes the given minimum and maximum values.

参数
MinThe minimum value to be included.
MaxThe maximum value to be included.
返回
A new range.
参见
All, AtLeast, AtMost, Empty, Exclusive, GreaterThan, LessThan

◆ Intersection() [1/2]

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Intersection ( const TArray< TRange< ElementType > > &  Ranges)
inlinestatic

Compute the intersection of many ranges.

参数
RangesThe ranges to intersect.
返回
The intersection.
参见
Difference, Hull, Union

◆ Intersection() [2/2]

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::Intersection ( const TRange< ElementType > &  X,
const TRange< ElementType > &  Y 
)
inlinestatic

Compute the intersection of two ranges.

The intersection of two ranges is the largest range that is contained by both ranges.

参数
XThe first range.
YThe second range.
返回
The intersection, or an empty range if the ranges do not overlap.
参见
Difference, Hull, Union

◆ IsDegenerate()

template<typename ElementType >
bool TRange< ElementType >::IsDegenerate ( ) const
inline

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]

返回
true if the range is degenerate, false otherwise.
参见
IsEmpty

◆ IsEmpty()

template<typename ElementType >
bool TRange< ElementType >::IsEmpty ( ) const
inline

Check whether this range is empty.

A range is empty if it contains no elements, i.e. (A, A) (A, A] [A, A)

返回
true if the range is empty, false otherwise.
参见
IsDegenerate

◆ LessThan()

template<typename ElementType >
static FORCEINLINE TRange TRange< ElementType >::LessThan ( ElementValueOrConstRef  Value)
inlinestatic

Create a right-bounded range that contains all elements less than the specified value.

参数
ValueThe value.
返回
A new range.
参见
All, AtLeast, AtMost, Empty, Exclusive, GreaterThan, Inclusive

◆ operator!=()

template<typename ElementType >
bool TRange< ElementType >::operator!= ( const TRange< ElementType > &  Other) const
inline

Compare this range with the specified range for inequality.

参数
OtherThe range to compare with.
返回
true if the ranges are not equal, false otherwise.

◆ operator==()

template<typename ElementType >
bool TRange< ElementType >::operator== ( const TRange< ElementType > &  Other) const
inline

Compare this range with the specified range for equality.

参数
OtherThe range to compare with.
返回
true if the ranges are equal, false otherwise.

◆ Overlaps()

template<typename ElementType >
bool TRange< ElementType >::Overlaps ( const TRange< ElementType > &  Other) const
inline

Check whether this range overlaps with another.

参数
OtherThe other range.
返回
true if the ranges overlap, false otherwise.

◆ SetLowerBound()

template<typename ElementType >
void TRange< ElementType >::SetLowerBound ( const BoundsType &  NewLowerBound)
inline

Assign the new lower bound for this range

参数
NewLowerBoundThe new lower bound to assign
参见
GetLowerBound

◆ SetLowerBoundValue()

template<typename ElementType >
void TRange< ElementType >::SetLowerBoundValue ( ElementValueOrConstRef  NewLowerBoundValue)
inline

Assign the new lower bound value for this range.

Current lower bound must not be open to call this method.

参数
NewLowerBoundValueThe new lower bound value to assign
参见
GetLowerBound

◆ SetUpperBound()

template<typename ElementType >
void TRange< ElementType >::SetUpperBound ( const BoundsType &  NewUpperBound)
inline

Assign the new upper bound for this range

参数
NewUpperBoundThe new upper bound to assign
参见
GetUpperBound

◆ SetUpperBoundValue()

template<typename ElementType >
void TRange< ElementType >::SetUpperBoundValue ( ElementValueOrConstRef  NewUpperBoundValue)
inline

Assign the new upper bound value for this range.

Current upper bound must not be open to call this method.

参数
NewUpperBoundValueThe new upper bound value to assign
参见
GetUpperBound

◆ Size()

template<typename ElementType >
template<typename DifferenceType >
DifferenceType TRange< ElementType >::Size ( ) const
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.

返回
Range size.

◆ Split()

template<typename ElementType >
TArray< TRange > TRange< ElementType >::Split ( ElementValueOrConstRef  Element) const
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.

参数
ElementThe element at which to split the range.

◆ Union()

template<typename ElementType >
static FORCEINLINE TArray< TRange > TRange< ElementType >::Union ( const TRange< ElementType > &  X,
const TRange< ElementType > &  Y 
)
inlinestatic

Return the union of two contiguous ranges.

A union is a range or series of ranges that contains both ranges.

参数
XThe first range.
YThe second range.
返回
The union, or both ranges if the two ranges are not contiguous, or no ranges if both ranges are empty.
参见
Difference, Hull, Intersection

友元及相关函数文档

◆ GetTypeHash

template<typename ElementType >
uint32 GetTypeHash ( const TRange< ElementType > &  Range)
friend

Gets the hash for the specified range.

参数
RangeThe range to get the hash for.
返回
Hash value.

◆ operator<<

template<typename ElementType >
class FArchive & operator<< ( class FArchive &  Ar,
TRange< ElementType > &  Range 
)
friend

Serializes the given range from or into the specified archive.

参数
ArThe archive to serialize from or into.
RangeThe range to serialize.
返回
The archive.

该类的文档由以下文件生成: