CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
System::MemoryExtensions::Details Namespace Reference

Functions

template<typename T , typename U >
int32_t Compare (const SharedPtr< T > &a, const SharedPtr< U > &b)
 Compares two smart pointers. More...
 
template<typename T >
int32_t Compare (const T &a, const T &b)
 Compares two arithmetic values. More...
 
template<typename T , typename U >
int32_t Compare (const SharedPtr< T > &a, const U &b)
 Compares a smart pointer with a value. More...
 
template<typename T >
int32_t LastIndexOfImpl (const ReadOnlySpan< T > &searchSpace, int32_t length, const T &value)
 Finds the last index of a value in a span. More...
 
template<typename T >
bool SequenceEqualImpl (const ReadOnlySpan< T > &first, const int32_t start, int32_t length, const ReadOnlySpan< T > &second)
 Checks if two spans are equal starting from specified positions. More...
 
template<typename TKey , typename TValue >
void IntroSort (Span< TKey > &keys, Span< TValue > &values, int32_t depthLimit, std::function< int32_t(const TKey &, const TKey &)> comparer)
 Internal implementation of introsort algorithm for key-value pairs. More...
 
template<typename TKey , typename TValue >
void SwapIfGreaterWithValues (Span< TKey > &keys, Span< TValue > &values, std::function< int32_t(const TKey &, const TKey &)> comparer, int32_t i, int32_t j)
 Swaps key-value pairs if comparison condition is met. More...
 
template<typename TKey , typename TValue >
void InsertionSort (Span< TKey > &keys, Span< TValue > &values, std::function< int32_t(const TKey &, const TKey &)> comparer)
 Performs insertion sort on key-value pairs. More...
 
template<typename TKey , typename TValue >
void HeapSort (Span< TKey > &keys, Span< TValue > &values, std::function< int32_t(const TKey &, const TKey &)> comparer)
 Performs heap sort on key-value pairs. More...
 
template<typename TKey , typename TValue >
void Heapify (Span< TKey > &keys, Span< TValue > &values, int32_t n, int32_t i, std::function< int32_t(const TKey &, const TKey &)> comparer)
 Maintains heap property for key-value pairs. More...
 
template<typename TKey , typename TValue >
int32_t PickPivotAndPartition (Span< TKey > &keys, Span< TValue > &values, std::function< int32_t(const TKey &, const TKey &)> comparer)
 Selects pivot and partitions key-value pairs for quicksort. More...
 
template<typename T , typename TValue , typename TCompareFunc >
int32_t BinarySearchImpl (const ReadOnlySpan< T > &span, const TValue &value, TCompareFunc compareFunc)
 Common binary search implementation. More...
 

Variables

const std::array< char16_t, 22 > DefaultWhitespaceChars
 Default whitespace characters used for trimming operations. More...
 
const ReadOnlySpan< char16_t > DefaultWhitespaceSpan
 Static ReadOnlySpan for default whitespace characters to avoid array creation. More...
 

Function Documentation

◆ BinarySearchImpl()

template<typename T , typename TValue , typename TCompareFunc >
int32_t System::MemoryExtensions::Details::BinarySearchImpl ( const ReadOnlySpan< T > &  span,
const TValue &  value,
TCompareFunc  compareFunc 
)

Common binary search implementation.

Template Parameters
TType of elements in span
TValueType of value to search for
TCompareFuncFunction type for comparison
Parameters
spanThe span to search
valueThe value to search for
compareFuncFunction that compares value with span element and returns int32_t (-1, 0, 1)
Returns
Index of found element or bitwise complement of insertion point

◆ Compare() [1/3]

template<typename T , typename U >
int32_t System::MemoryExtensions::Details::Compare ( const SharedPtr< T > &  a,
const SharedPtr< U > &  b 
)

Compares two smart pointers.

Template Parameters
TType of first smart pointer
UType of second smart pointer
Parameters
aFirst smart pointer
bSecond smart pointer
Returns
Comparison result (0 if equal, -1 if a < b, 1 if a > b)

◆ Compare() [2/3]

template<typename T , typename U >
int32_t System::MemoryExtensions::Details::Compare ( const SharedPtr< T > &  a,
const U &  b 
)

Compares a smart pointer with a value.

Template Parameters
TType pointed to by smart pointer
UType of value
Parameters
aSmart pointer
bValue
Returns
Comparison result (0 if equal, -1 if a < b, 1 if a > b)

◆ Compare() [3/3]

template<typename T >
int32_t System::MemoryExtensions::Details::Compare ( const T &  a,
const T &  b 
)

Compares two arithmetic values.

Template Parameters
TArithmetic type
Parameters
aFirst value
bSecond value
Returns
Comparison result (0 if equal, -1 if a < b, 1 if a > b)

◆ Heapify()

template<typename TKey , typename TValue >
void System::MemoryExtensions::Details::Heapify ( Span< TKey > &  keys,
Span< TValue > &  values,
int32_t  n,
int32_t  i,
std::function< int32_t(const TKey &, const TKey &)>  comparer 
)

Maintains heap property for key-value pairs.

Template Parameters
TKeyThe type of keys
TValueThe type of values
Parameters
keysThe span of keys in the heap
valuesThe span of values in the heap
nSize of the heap
iIndex to heapify from
comparerComparison function for keys

◆ HeapSort()

template<typename TKey , typename TValue >
void System::MemoryExtensions::Details::HeapSort ( Span< TKey > &  keys,
Span< TValue > &  values,
std::function< int32_t(const TKey &, const TKey &)>  comparer 
)

Performs heap sort on key-value pairs.

Template Parameters
TKeyThe type of keys
TValueThe type of values
Parameters
keysThe span of keys to sort
valuesThe span of values to sort
comparerComparison function for keys

◆ InsertionSort()

template<typename TKey , typename TValue >
void System::MemoryExtensions::Details::InsertionSort ( Span< TKey > &  keys,
Span< TValue > &  values,
std::function< int32_t(const TKey &, const TKey &)>  comparer 
)

Performs insertion sort on key-value pairs.

Template Parameters
TKeyThe type of keys
TValueThe type of values
Parameters
keysThe span of keys to sort
valuesThe span of values to sort
comparerComparison function for keys

◆ IntroSort()

template<typename TKey , typename TValue >
void System::MemoryExtensions::Details::IntroSort ( Span< TKey > &  keys,
Span< TValue > &  values,
int32_t  depthLimit,
std::function< int32_t(const TKey &, const TKey &)>  comparer 
)

Internal implementation of introsort algorithm for key-value pairs.

Template Parameters
TKeyThe type of keys
TValueThe type of values
Parameters
keysThe span of keys to sort
valuesThe span of values to sort
depthLimitMaximum recursion depth before switching to heapsort
comparerComparison function for keys

◆ LastIndexOfImpl()

template<typename T >
int32_t System::MemoryExtensions::Details::LastIndexOfImpl ( const ReadOnlySpan< T > &  searchSpace,
int32_t  length,
const T &  value 
)

Finds the last index of a value in a span.

Template Parameters
TType of elements in span
Parameters
searchSpaceSpan to search
lengthLength to search within
valueValue to find
Returns
Last index of the value, or -1 if not found

◆ PickPivotAndPartition()

template<typename TKey , typename TValue >
int32_t System::MemoryExtensions::Details::PickPivotAndPartition ( Span< TKey > &  keys,
Span< TValue > &  values,
std::function< int32_t(const TKey &, const TKey &)>  comparer 
)

Selects pivot and partitions key-value pairs for quicksort.

Template Parameters
TKeyThe type of keys
TValueThe type of values
Parameters
keysThe span of keys to partition
valuesThe span of values to partition
comparerComparison function for keys
Returns
The pivot index after partitioning

◆ SequenceEqualImpl()

template<typename T >
bool System::MemoryExtensions::Details::SequenceEqualImpl ( const ReadOnlySpan< T > &  first,
const int32_t  start,
int32_t  length,
const ReadOnlySpan< T > &  second 
)

Checks if two spans are equal starting from specified positions.

Template Parameters
TType of elements in spans
Parameters
firstFirst span
startStarting index in first span
lengthNumber of elements to compare
secondSecond span
Returns
true if the specified ranges are equal, false otherwise

◆ SwapIfGreaterWithValues()

template<typename TKey , typename TValue >
void System::MemoryExtensions::Details::SwapIfGreaterWithValues ( Span< TKey > &  keys,
Span< TValue > &  values,
std::function< int32_t(const TKey &, const TKey &)>  comparer,
int32_t  i,
int32_t  j 
)

Swaps key-value pairs if comparison condition is met.

Template Parameters
TKeyThe type of keys
TValueThe type of values
Parameters
keysThe span of keys
valuesThe span of values
comparerComparison function for keys
iFirst index to compare
jSecond index to compare

Variable Documentation

◆ DefaultWhitespaceChars

const std::array<char16_t, 22> System::MemoryExtensions::Details::DefaultWhitespaceChars
extern

Default whitespace characters used for trimming operations.

◆ DefaultWhitespaceSpan

const ReadOnlySpan<char16_t> System::MemoryExtensions::Details::DefaultWhitespaceSpan
extern

Static ReadOnlySpan for default whitespace characters to avoid array creation.