CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
System::Range Class Reference

Represents a range with a start and end index. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type. More...

#include <range.h>

Inherits System::Details::BoxableObjectBase.

Public Member Functions

constexpr Range () noexcept
 Constructs an empty range. More...
 
constexpr Range (const Index &start, const Index &end) noexcept
 Constructs a Range from the specified start and end indexes. More...
 
const Indexget_Start () const noexcept
 Gets the Start index. More...
 
const Indexget_End () const noexcept
 Gets the End index. More...
 
System::ValueTuple< int32_t, int32_t > GetOffsetAndLength (int32_t length) const
 Computes the zero-based start offset and length for the specified collection length. More...
 
bool Equals (const Range &other) const
 Determines whether the current range is equal to the specified range. More...
 
int32_t GetHashCode () const
 Returns a hash code for the current range. More...
 

Static Public Member Functions

static constexpr Range get_All () noexcept
 Returns a Range that represents the whole collection. More...
 
static constexpr Range StartAt (const Index &start) noexcept
 Creates a range that begins at the specified start index and extends to the end of the collection. More...
 
static constexpr Range EndAt (const Index &end) noexcept
 Creates a range that begins at the start of the collection and ends at the specified end index. More...
 

Detailed Description

Represents a range with a start and end index. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

Constructor & Destructor Documentation

◆ Range() [1/2]

constexpr System::Range::Range ( )
inlineconstexprnoexcept

Constructs an empty range.

◆ Range() [2/2]

constexpr System::Range::Range ( const Index start,
const Index end 
)
inlineconstexprnoexcept

Constructs a Range from the specified start and end indexes.

Parameters
startThe start index of the range.
endThe end index of the range.

Member Function Documentation

◆ EndAt()

static constexpr Range System::Range::EndAt ( const Index end)
inlinestaticconstexprnoexcept

Creates a range that begins at the start of the collection and ends at the specified end index.

Parameters
endThe ending index of the range.
Returns
A Range object that starts at the beginning of the collection and ends at end.

◆ Equals()

bool System::Range::Equals ( const Range other) const
inline

Determines whether the current range is equal to the specified range.

Parameters
otherThe range to compare with.
Returns
True if both ranges have the same start and end indexes, otherwise false.

◆ get_All()

static constexpr Range System::Range::get_All ( )
inlinestaticconstexprnoexcept

Returns a Range that represents the whole collection.

Returns
A Range object that selects all elements.

◆ get_End()

const Index & System::Range::get_End ( ) const
inlinenoexcept

Gets the End index.

◆ get_Start()

const Index & System::Range::get_Start ( ) const
inlinenoexcept

Gets the Start index.

◆ GetHashCode()

int32_t System::Range::GetHashCode ( ) const
inline

Returns a hash code for the current range.

Returns
A hash code computed from the start and end indexes.

◆ GetOffsetAndLength()

System::ValueTuple< int32_t, int32_t > System::Range::GetOffsetAndLength ( int32_t  length) const
inline

Computes the zero-based start offset and length for the specified collection length.

Parameters
lengthThe length of the collection.
Returns
The tuple containing zero-based index from the start of the collection and the number of elements selected by the range.
Exceptions
ArgumentOutOfRangeExceptionif the length is invalid or the start index is out of range.

◆ StartAt()

static constexpr Range System::Range::StartAt ( const Index start)
inlinestaticconstexprnoexcept

Creates a range that begins at the specified start index and extends to the end of the collection.

Parameters
startThe starting index of the range.
Returns
A Range object that starts at start and ends at the end of the collection.