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

Represents an index into a collection. The index can be from the start or from the end. 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 <index.h>

Inherits System::Details::BoxableObjectBase.

Public Member Functions

constexpr Index () noexcept
 Constructs an instance that represents the start of a collection. More...
 
constexpr Index (int32_t value) noexcept
 Constructs an instance that represents the specified position from the start of a collection. More...
 
constexpr Index (int32_t value, bool from_end) noexcept
 Constructs an instance that represents the specified index. More...
 
constexpr int32_t get_Value () const noexcept
 Gets the index value. More...
 
constexpr bool get_IsFromEnd () const noexcept
 Gets a value that indicates whether the index is from the end. More...
 
int32_t GetOffset (int32_t length) const
 Converts the current Index into an offset from the start of a collection with the specified length. More...
 
bool Equals (const Index &other) const
 Determines whether the current instance and the specified Index represent the same position. More...
 
int32_t GetHashCode () const
 Returns a hash code for the current index. More...
 

Static Public Member Functions

static constexpr Index FromEnd (int32_t value) noexcept
 Creates an Index that is relative to the end of the collection. More...
 
static constexpr Index get_Start () noexcept
 Gets an Index object representing the start of a collection. More...
 
static constexpr Index get_End () noexcept
 Gets an Index object representing the end of a collection. More...
 

Detailed Description

Represents an index into a collection. The index can be from the start or from the end. 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

◆ Index() [1/3]

constexpr System::Index::Index ( )
inlineconstexprnoexcept

Constructs an instance that represents the start of a collection.

◆ Index() [2/3]

constexpr System::Index::Index ( int32_t  value)
inlineconstexprnoexcept

Constructs an instance that represents the specified position from the start of a collection.

Parameters
valueThe zero-based index from the start.

◆ Index() [3/3]

constexpr System::Index::Index ( int32_t  value,
bool  from_end 
)
inlineconstexprnoexcept

Constructs an instance that represents the specified index.

Parameters
valueThe index value.
from_endTrue if the index is relative to the end of the collection.

Member Function Documentation

◆ Equals()

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

Determines whether the current instance and the specified Index represent the same position.

Parameters
otherThe index to compare with.
Returns
True if both indexes have the same value and direction, otherwise false.

◆ FromEnd()

static constexpr Index System::Index::FromEnd ( int32_t  value)
inlinestaticconstexprnoexcept

Creates an Index that is relative to the end of the collection.

Parameters
valueThe index value from the end.
Returns
An Index instance that refers to the end-relative position.

◆ get_End()

static constexpr Index System::Index::get_End ( )
inlinestaticconstexprnoexcept

Gets an Index object representing the end of a collection.

◆ get_IsFromEnd()

constexpr bool System::Index::get_IsFromEnd ( ) const
inlineconstexprnoexcept

Gets a value that indicates whether the index is from the end.

◆ get_Start()

static constexpr Index System::Index::get_Start ( )
inlinestaticconstexprnoexcept

Gets an Index object representing the start of a collection.

◆ get_Value()

constexpr int32_t System::Index::get_Value ( ) const
inlineconstexprnoexcept

Gets the index value.

◆ GetHashCode()

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

Returns a hash code for the current index.

Returns
A hash code derived from the index value and direction.

◆ GetOffset()

int32_t System::Index::GetOffset ( int32_t  length) const
inline

Converts the current Index into an offset from the start of a collection with the specified length.

Parameters
lengthThe length of the collection.
Returns
The zero-based offset from the start of the collection.