2#ifndef _aspose_system_memory_extensions_h_
3#define _aspose_system_memory_extensions_h_
7#include <system/span.h>
8#include <system/object.h>
9#include <system/object_ext.h>
10#include <system/details/stack_array.h>
11#include <system/smart_ptr.h>
12#include <system/exceptions.h>
13#include <system/comparison.h>
18namespace MemoryExtensions {
32template <
typename T,
typename U>
48 return (*a).CompareTo(b);
69template <
typename T,
typename U>
73 return (*a).CompareTo(b);
173template <
typename TKey,
typename TValue>
175 std::function<int32_t(
const TKey&,
const TKey&)> comparer)
177 int32_t partitionSize = keys.get_Length();
178 while (partitionSize > 1)
180 if (partitionSize <= 16)
182 if (partitionSize == 2)
188 if (partitionSize == 3)
210 int32_t rightSize = partitionSize - p - 1;
213 IntroSort(keys.Slice(p + 1, rightSize), values.Slice(p + 1, rightSize), depthLimit, comparer);
229template <
typename TKey,
typename TValue>
231 std::function<int32_t(
const TKey&,
const TKey&)> comparer, int32_t i, int32_t j)
233 if (comparer(keys.get(i), keys.get(j)) > 0)
235 std::swap(keys.get(i), keys.get(j));
236 std::swap(values.get(i), values.get(j));
246template <
typename TKey,
typename TValue>
249 for (int32_t i = 0; i < keys.get_Length() - 1; i++)
251 TKey t = keys.get(i + 1);
252 TValue tValue = values.get(i + 1);
255 while (j >= 0 && keys.get(j) != t && !comparer(t, keys.get(j)))
257 keys.get(j + 1) = keys.get(j);
258 values.get(j + 1) = values.get(j);
263 values.get(j + 1) = tValue;
273template <
typename TKey,
typename TValue>
277 for (int32_t i = keys.get_Length() / 2 - 1; i >= 0; i--)
279 Heapify(keys, values, keys.get_Length(), i, comparer);
283 for (int32_t i = keys.get_Length() - 1; i > 0; i--)
285 std::swap(keys.get(0), keys.get(i));
286 std::swap(values.get(0), values.get(i));
287 Heapify(keys, values, i, 0, comparer);
299template <
typename TKey,
typename TValue>
301 std::function<int32_t(
const TKey&,
const TKey&)> comparer)
304 int32_t left = 2 * i + 1;
305 int32_t right = 2 * i + 2;
307 if (left < n && comparer(keys.get(left), keys.get(largest)) > 0)
312 if (right < n && comparer(keys.get(right), keys.get(largest)) > 0)
319 std::swap(keys.get(i), keys.get(largest));
320 std::swap(values.get(i), values.get(largest));
321 Heapify(keys, values, n, largest, comparer);
332template <
typename TKey,
typename TValue>
334 std::function<int32_t(
const TKey&,
const TKey&)> comparer)
337 int32_t middle = keys.get_Length() / 2;
338 int32_t last = keys.get_Length() - 1;
341 if (comparer(keys.get(0), keys.get(middle)) > 0)
343 std::swap(keys.get(0), keys.get(middle));
344 std::swap(values.get(0), values.get(middle));
346 if (comparer(keys.get(0), keys.get(last)) > 0)
348 std::swap(keys.get(0), keys.get(last));
349 std::swap(values.get(0), values.get(last));
351 if (comparer(keys.get(middle), keys.get(last)) > 0)
353 std::swap(keys.get(middle), keys.get(last));
354 std::swap(values.get(middle), values.get(last));
358 std::swap(keys.get(middle), keys.get(last));
359 std::swap(values.get(middle), values.get(last));
361 TKey pivot = keys.get(last);
364 for (int32_t j = 0; j < last; j++)
366 if (comparer(keys.get(j), pivot) <= 0)
369 std::swap(keys.get(i), keys.get(j));
370 std::swap(values.get(i), values.get(j));
374 std::swap(keys.get(i + 1), keys.get(last));
375 std::swap(values.get(i + 1), values.get(last));
387template <
typename T,
typename TValue,
typename TCompareFunc>
391 int32_t hi = span.get_Length() - 1;
396 int32_t i =
static_cast<int32_t
>((
static_cast<uint32_t
>(hi) +
static_cast<uint32_t
>(lo)) >> 1);
397 int32_t c = compareFunc(value, span.get(i));
433 if (array ==
nullptr)
435 throw ArgumentNullException(u
"array is null");
437 if (start < 0 || (length < 0 && length != -1) ||
438 (length == -1 ? start > array->get_Length() : start + length > array->get_Length()))
440 throw ArgumentOutOfRangeException(u
"start or length is out of range");
444 length = array->get_Length() - start;
446 return Span<T>(array, start, length);
455template <
typename T,
typename TComparable>
459 [](
const TComparable& search_value,
const T& container_value) -> int32_t {
471template <
typename T,
typename TComparer>
475 [&comparerPtr](
const T& search_value,
const T& container_value) -> int32_t {
476 return comparerPtr->Compare(search_value, container_value);
486template <
typename T,
typename TComparable>
499template <
typename T,
typename TComparer>
513 int32_t commonLength = 0;
514 int32_t minLength = std::min(span.get_Length(), other.get_Length());
517 for (int32_t i = 0; i < minLength; ++i)
561template <
typename T,
typename TEqualityComparer>
565 int32_t commonLength = 0;
566 int32_t minLength = std::min(span.get_Length(), other.get_Length());
569 for (int32_t i = 0; i < minLength; ++i)
572 (comparer !=
nullptr && comparer->Equals(span.get(i), other.get(i))))
593template <
typename T,
typename TEqualityComparer>
607template <
typename T,
typename TEqualityComparer>
639 return std::find_if(span.begin(), span.end(), [&value](
const T& item) { return System::ObjectExt::Equals(value, item); }) !=
651 return std::find(span.begin(), span.end(), value) != span.end();
712 for (
const auto& value : values)
743 for (
auto& member : span)
776 for (
auto& member : span)
806 for (
auto& member : span)
835 switch (values.get_Length())
838 return span.get_IsEmpty() ? false :
true;
850 for (
auto& member : span)
881 for (
const auto& value : span)
883 if (value < lowInclusive || value > highInclusive)
900 for (
const auto& value : span)
902 if (value < lowInclusive || value > highInclusive)
919 for (
const auto& value : span)
921 if (value >= lowInclusive && value <= highInclusive)
938 for (
const auto& value : span)
940 if (value >= lowInclusive && value <= highInclusive)
967 for (
const auto& item : span)
985 switch (value.get_Length())
991 return Count(span, value.get(0));
997 while ((pos =
IndexOf(currentSpan, value)) >= 0)
1000 currentSpan = currentSpan.Slice(pos + value.get_Length());
1011template <
typename T>
1022template <
typename T>
1041template <
typename T>
1044 if (span.get_Length() == 0)
1056template <
typename T>
1059 int32_t spanLength = span.get_Length();
1060 int32_t valueLength = value.get_Length();
1062 if (valueLength > spanLength)
1067 if (valueLength == spanLength)
1072 return SequenceEqual(span.Slice(spanLength - valueLength), value);
1080template <
typename T>
1091template <
typename T>
1102template <
typename T>
1129template <
typename T>
1132 if (value.get_Length() == 0)
1137 const T& valueHead = value.get(0);
1138 int32_t valueTailLength = value.get_Length() - 1;
1143 if (index + valueTailLength > span.get_Length())
1149 int32_t remainingSearchSpaceLength = span.get_Length() - index - valueTailLength;
1150 int32_t relativeIndex = -1;
1152 for (int32_t i = 0; i < remainingSearchSpaceLength; ++i)
1161 if (relativeIndex == -1)
1166 index += relativeIndex;
1169 bool tailMatches =
true;
1170 for (int32_t i = 0; i < valueTailLength; ++i)
1172 if (span.get(index + 1 + i) != value.get(1 + i))
1174 tailMatches =
false;
1195template <
typename T>
1198 for (int32_t i = 0; i < span.get_Length(); ++i)
1213template <
typename T>
1224template <
typename T>
1236template <
typename T>
1239 for (int32_t i = 0; i < span.get_Length(); ++i)
1256template <
typename T>
1259 for (int32_t i = 0; i < span.get_Length(); ++i)
1276template <
typename T>
1289template <
typename T>
1300template <
typename T>
1303 for (int32_t i = 0; i < span.get_Length(); ++i)
1305 for (int32_t j = 0; j < values.get_Length(); ++j)
1321template <
typename T>
1332template <
typename T>
1335 for (int32_t i = 0; i < span.get_Length(); ++i)
1352template <
typename T>
1355 for (int32_t i = 0; i < span.get_Length(); ++i)
1373template <
typename T>
1376 for (int32_t i = 0; i < span.get_Length(); ++i)
1392template <
typename T>
1404template <
typename T>
1417template <
typename T>
1428template <
typename T>
1431 for (int32_t i = 0; i < span.get_Length(); ++i)
1434 for (int32_t j = 0; j < values.get_Length(); ++j)
1455template <
typename T>
1467template <
typename T>
1470 for (int32_t i = 0; i < span.get_Length(); ++i)
1486template <
typename T>
1498template <
typename T>
1501 for (int32_t i = 0; i < span.get_Length(); ++i)
1518template <
typename T>
1542template <
typename T>
1545 if (value.get_Length() == 0)
1546 return span.get_Length();
1548 int32_t valueTailLength = value.get_Length() - 1;
1549 if (valueTailLength == 0)
1551 return LastIndexOf<T>(span, value.get(0));
1556 T valueHead = value.get(0);
1561 int32_t remainingSearchSpaceLength = span.get_Length() - index - valueTail.get_Length();
1562 if (remainingSearchSpaceLength <= 0)
1566 int32_t relativeIndex = Details::LastIndexOfImpl<T>(span, remainingSearchSpaceLength, valueHead);
1567 if (relativeIndex < 0)
1571 if (Details::SequenceEqualImpl<T>(span, relativeIndex + 1, valueTail.get_Length(), valueTail))
1572 return relativeIndex;
1574 index += remainingSearchSpaceLength - relativeIndex;
1584template <
typename T>
1587 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1602template <
typename T>
1613template <
typename T>
1626template <
typename T>
1629 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1647template <
typename T>
1659template <
typename T>
1662 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1678template <
typename T>
1689template <
typename T>
1692 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1694 for (int32_t j = 0; j < values.get_Length(); ++j)
1710template <
typename T>
1721template <
typename T>
1734template <
typename T>
1737 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1739 const T& current = span.get(i);
1756template <
typename T>
1768template <
typename T>
1771 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1773 const T& current = span.get(i);
1788template <
typename T>
1799template <
typename T>
1802 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1804 T current = span.get(i);
1818template <
typename T>
1829template <
typename T>
1832 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1834 const T& current = span.get(i);
1836 for (
auto& value : values)
1857template <
typename T>
1868template <
typename T>
1880template <
typename T>
1883 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1899template <
typename T>
1911template <
typename T>
1914 for (int32_t i = span.get_Length() - 1; i >= 0; --i)
1930template <
typename T>
1941template <
typename T>
1945 return Overlaps(span, other, offset);
1953template <
typename T>
1965template <
typename T>
1968 if (span.get_IsEmpty() || other.get_IsEmpty())
1973 ptrdiff_t Offset = other.begin() - span.begin();
1974 bool isOverlap = (Offset >= 0 && Offset < span.get_Length()) || (Offset < 0 && -Offset < other.get_Length());
1978 elementOffset =
static_cast<int32_t
>(Offset);
1993template <
typename T>
2004template <
typename T>
2007 for (int32_t i = 0; i < span.get_Length(); ++i)
2011 span.get(i) = newValue;
2023template <
typename T>
2026 if (destination.get_Length() < source.get_Length())
2028 throw ArgumentException(u
"Destination span is smaller than source span.");
2031 for (int32_t i = 0; i < source.get_Length(); ++i)
2035 destination.get(i) = newValue;
2039 destination.get(i) = source.get(i);
2047template <
typename T>
2051 int32_t right = span.get_Length() - 1;
2052 while (left < right)
2054 std::swap(span.get(left), span.get(right));
2065template <
typename T>
2068 auto spanIt = span.begin();
2069 auto otherIt = other.begin();
2070 auto spanEnd = span.end();
2071 auto otherEnd = other.end();
2073 while (spanIt != spanEnd && otherIt != otherEnd)
2075 if (*spanIt < *otherIt)
2079 if (*spanIt > *otherIt)
2089 if (span.get_Length() < other.get_Length())
2093 if (span.get_Length() > other.get_Length())
2106template <
typename T>
2117template <
typename T>
2128template <
typename T>
2131 if (first == second)
2134 if (first.get_Length() != second.get_Length())
2139 int32_t length = second.get_Length();
2149template <
typename T>
2162template <
typename T,
typename TComparer>
2165 if (comparer ==
nullptr)
2170 if (span.get_Length() != other.get_Length())
2175 for (int32_t i = 0; i < span.get_Length(); ++i)
2177 if (!comparer->Equals(span.get(i), other.get(i)))
2192template <
typename T,
typename TComparer>
2203template <
typename T,
typename TComparer>
2206 std::sort(span.begin(), span.end(), [&comparer](
const T& a,
const T& b) ->
bool { return comparer->Compare(a, b) < 0; });
2212template <
typename T>
2215 std::sort(span.begin(), span.end());
2226template <
typename TKey,
typename TValue,
typename TComparer>
2229 if (keys.get_Length() != values.get_Length())
2231 throw ArgumentException(u
"Keys and items must have the same length.");
2233 if (keys.get_Length() > 1)
2235 int32_t depthLimit = 2 * (
static_cast<int32_t
>(std::log2(keys.get_Length())) + 1);
2236 Details::IntroSort<TKey, TValue>(keys, values, depthLimit,
2237 [&comparer](TKey a, TKey b) ->
bool {
return comparer->Compare(a, b) > 0; });
2248template <
typename TKey,
typename TValue>
2251 if (keys.get_Length() != values.get_Length())
2253 throw ArgumentException(u
"Keys and items must have the same length.");
2255 if (keys.get_Length() > 1)
2257 int32_t depthLimit = 2 * (
static_cast<int32_t
>(std::log2(keys.get_Length())) + 1);
2258 Details::IntroSort<TKey, TValue>(keys, values, depthLimit,
2259 [&](
const TKey& a,
const TKey& b) {
return !comparer(a, b); });
2269template <
typename TKey,
typename TValue>
2272 if (keys.get_Length() != values.get_Length())
2274 throw ArgumentException(u
"Keys and items must have the same length.");
2276 if (keys.get_Length() > 1)
2278 int32_t depthLimit = 2 * (
static_cast<int32_t
>(std::log2(keys.get_Length())) + 1);
2279 Details::IntroSort<TKey, TValue>(keys, values, depthLimit, [&](
const TKey& a,
const TKey& b) {
return a > b; });
2288template <
typename T>
2291 if (span.get_Length() == 0)
2295 return System::ObjectExt::Equals<T>(span.get(0), value);
2304 if (span.get_Length() == 0)
2309 return (span.get(0)).Equals(value);
2317template <
typename T>
2320 if (value.get_Length() > span.get_Length())
2325 for (int32_t i = 0; i < value.get_Length(); ++i)
2341template <
typename T>
2352template <
typename T>
2399template <
typename T>
2410template <
typename T>
2421template <
typename T>
2424 if (span.get_IsEmpty())
2430 int32_t end = span.get_Length() - 1;
2433 while (start <= end &&
Contains(trimElements, span.get(start)))
2439 while (end >= start &&
Contains(trimElements, span.get(end)))
2444 return span.Slice(start, end - start + 1);
2452template <
typename T>
2455 if (span.get_IsEmpty())
2461 int32_t end = span.get_Length() - 1;
2464 while (start <= end &&
Contains(trimElements, span.get(start)))
2470 while (end >= start &&
Contains(trimElements, span.get(end)))
2475 return span.Slice(start, end - start + 1);
2499template <
typename T>
2502 int32_t endIndex = span.get_Length() - 1;
2507 return span.Slice(0, endIndex + 1);
2515template <
typename T>
2518 int32_t endIndex = span.get_Length() - 1;
2523 return span.Slice(0, endIndex + 1);
2531template <
typename T>
2534 int32_t endIndex = span.get_Length() - 1;
2535 while (endIndex >= 0 &&
Contains(trimElements, span.get(endIndex)))
2539 return span.Slice(0, endIndex + 1);
2547template <
typename T>
2550 int32_t endIndex = span.get_Length() - 1;
2551 while (endIndex >= 0 &&
Contains(trimElements, span.get(endIndex)))
2555 return span.Slice(0, endIndex + 1);
2580 int32_t endIndex = span.get_Length() - 1;
2581 while (endIndex >= 0 && span.get(endIndex) == trimchar)
2585 return span.Slice(0, endIndex + 1);
2594 int32_t endIndex = span.get_Length() - 1;
2595 while (endIndex >= 0 && span.get(endIndex) == trimchar)
2599 return span.Slice(0, endIndex + 1);
2608 int32_t endIndex = span.get_Length() - 1;
2609 while (endIndex >= 0 &&
Contains(trimChars, span.get(endIndex)))
2613 return span.Slice(0, endIndex + 1);
2622 int32_t endIndex = span.get_Length() - 1;
2623 while (endIndex >= 0 &&
Contains(trimchars, span.get(endIndex)))
2627 return span.Slice(0, endIndex + 1);
2635template <
typename T>
2638 int32_t startIndex = 0;
2643 return span.Slice(startIndex);
2651template <
typename T>
2654 int32_t startIndex = 0;
2659 return span.Slice(startIndex);
2667template <
typename T>
2670 int32_t startIndex = 0;
2671 while (startIndex < span.get_Length() &&
Contains(trimElements, span.get(startIndex)))
2675 return span.Slice(startIndex);
2683template <
typename T>
2686 int32_t startIndex = 0;
2687 while (startIndex < span.get_Length() &&
Contains(trimElements, span.get(startIndex)))
2691 return span.Slice(startIndex);
2716 int32_t startIndex = 0;
2717 while (startIndex < span.get_Length() && span.get(startIndex) == trimchar)
2721 return span.Slice(startIndex);
2730 int32_t startIndex = 0;
2731 while (startIndex < span.get_Length() && span.get(startIndex) == trimchar)
2735 return span.Slice(startIndex);
2744 int32_t startIndex = 0;
2745 while (startIndex < span.get_Length() &&
Contains(trimchars, span.get(startIndex)))
2749 return span.Slice(startIndex);
2758 int32_t startIndex = 0;
2759 while (startIndex < span.get_Length() &&
Contains(trimchars, span.get(startIndex)))
2763 return span.Slice(startIndex);
Represents a pointer to the method that compares two objects of the same type. This type should be al...
Definition: comparison.h:93
static std::enable_if< IsExceptionWrapper< T >::value, bool >::type Equals(const T &obj, const T2 &another)
Definition: object_ext.h:34
Forward to use within Span class.
Definition: span.h:396
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Represents a contiguous region of arbitrary memory similar to C++20's std::span.
Definition: span.h:357
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
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.
Definition: memory_extensions.h:130
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.
Definition: memory_extensions.h:230
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.
Definition: memory_extensions.h:333
void HeapSort(Span< TKey > &keys, Span< TValue > &values, std::function< int32_t(const TKey &, const TKey &)> comparer)
Performs heap sort on key-value pairs.
Definition: memory_extensions.h:274
const std::array< char16_t, 22 > DefaultWhitespaceChars
Default whitespace characters used for trimming operations.
void InsertionSort(Span< TKey > &keys, Span< TValue > &values, std::function< int32_t(const TKey &, const TKey &)> comparer)
Performs insertion sort on key-value pairs.
Definition: memory_extensions.h:247
const ReadOnlySpan< char16_t > DefaultWhitespaceSpan
Static ReadOnlySpan for default whitespace characters to avoid array creation.
int32_t LastIndexOfImpl(const ReadOnlySpan< T > &searchSpace, int32_t length, const T &value)
Finds the last index of a value in a span.
Definition: memory_extensions.h:83
int32_t Compare(const SharedPtr< T > &a, const SharedPtr< U > &b)
Compares two smart pointers.
Definition: memory_extensions.h:33
int32_t BinarySearchImpl(const ReadOnlySpan< T > &span, const TValue &value, TCompareFunc compareFunc)
Common binary search implementation.
Definition: memory_extensions.h:388
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.
Definition: memory_extensions.h:300
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.
Definition: memory_extensions.h:174
int32_t BinarySearch(const ReadOnlySpan< T > &span, const TComparable &comparable)
Performs binary search on a sorted span.
Definition: memory_extensions.h:456
int32_t SequenceCompareTo(const ReadOnlySpan< T > &span, const ReadOnlySpan< T > &other)
Compares two ReadOnlySpans lexicographically.
Definition: memory_extensions.h:2066
int32_t IndexOfAny(const ReadOnlySpan< T > &span, const T &value0, const T &value1)
Finds the index of the first occurrence of any of two specified values in a ReadOnlySpan<T>
Definition: memory_extensions.h:1237
bool Overlaps(const ReadOnlySpan< T > &span, const ReadOnlySpan< T > &other)
Determines if two ReadOnlySpans overlap in memory without calculating offset.
Definition: memory_extensions.h:1942
int32_t LastIndexOfAnyExceptInRange(const ReadOnlySpan< T > &span, const T &lowInclusive, const T &highInclusive)
Finds the last occurrence of any element outside the specified range within a span.
Definition: memory_extensions.h:1881
ReadOnlySpan< T > TrimEnd(const ReadOnlySpan< T > &span, const T &trimElement)
Trims specified element from the end of a typed span.
Definition: memory_extensions.h:2500
int32_t LastIndexOfAnyInRange(const ReadOnlySpan< T > &span, const T &lowInclusive, const T &highInclusive)
Finds the last occurrence of any element within the specified range within a span.
Definition: memory_extensions.h:1912
int32_t ToUpperInvariant(const ReadOnlySpan< char16_t > &source, Span< char16_t > &destination)
Converts characters to uppercase using invariant culture.
int32_t IndexOf(const ReadOnlySpan< char16_t > &span, const ReadOnlySpan< char16_t > &value, StringComparison comparisonType)
Finds the index of a ReadOnlySpan<char16_t> value in a ReadOnlySpan<char16_t> with StringComparison.
void Reverse(Span< T > &span)
Reverses the order of elements in a Span in-place.
Definition: memory_extensions.h:2048
bool ContainsAnyInRange(const ReadOnlySpan< T > &span, const T &lowInclusive, const T &highInclusive)
Checks if a read-only span contains any element within the specified range.
Definition: memory_extensions.h:917
void CopyTo(const ArrayPtr< T > &source, Span< T > &destination)
Copies elements from an array to a span.
Definition: memory_extensions.h:953
bool StartsWith(const ReadOnlySpan< T > &span, const T &value)
Checks if the span starts with the specified value.
Definition: memory_extensions.h:2289
void Replace(Span< T > &span, const T &oldValue, const T &newValue)
Replaces all occurrences of a value with a new value in a Span.
Definition: memory_extensions.h:2005
bool Contains(const ReadOnlySpan< char16_t > &span, const ReadOnlySpan< char16_t > &value, StringComparison comparisonType)
Checks if a character span contains another character span with specified comparison rules.
bool ContainsAnyExceptInRange(const ReadOnlySpan< T > &span, const T &lowInclusive, const T &highInclusive)
Checks if a read-only span contains any element outside the specified range.
Definition: memory_extensions.h:879
bool Equals(const ReadOnlySpan< char16_t > &span, const ReadOnlySpan< char16_t > &other, StringComparison comparisonType)
Compares two ReadOnlySpan<char16_t> for equality using StringComparison.
int32_t ToLower(const ReadOnlySpan< char16_t > &source, Span< char16_t > &destination, const SharedPtr< Globalization::CultureInfo > &culture)
Converts characters to lowercase using specified culture.
int32_t LastIndexOfAnyExcept(const ReadOnlySpan< T > &span, const T &value0, const T &value1, const T &value2)
Finds the last occurrence of any element except three specified values within a span.
Definition: memory_extensions.h:1735
int32_t IndexOfAnyExcept(const ReadOnlySpan< T > &span, const T &value)
Finds the index of the first element that is not equal to the specified value in a ReadOnlySpan<T>
Definition: memory_extensions.h:1333
int32_t CommonPrefixLength(const ReadOnlySpan< T > &span, const ReadOnlySpan< T > &other)
Finds the length of the common prefix between two spans.
Definition: memory_extensions.h:511
bool SequenceEqual(const ReadOnlySpan< T > &first, const ReadOnlySpan< T > &second)
Determines if two ReadOnlySpans contain identical elements in the same order.
Definition: memory_extensions.h:2129
int32_t LastIndexOfAny(const ReadOnlySpan< T > &span, const T &value0, const T &value1, const T &value2)
Finds the last occurrence of any of three specified values within a span.
Definition: memory_extensions.h:1627
ReadOnlySpan< char16_t > AsSpan(const String &text, int32_t start=0, int32_t length=-1)
Creates a read-only span from a string.
int32_t IndexOfAnyExceptInRange(const ReadOnlySpan< T > &span, const T &lowInclusive, const T &highInclusive)
Finds the index of the first element that is outside the specified range in a ReadOnlySpan<T>
Definition: memory_extensions.h:1468
bool ContainsAny(const ReadOnlySpan< T > &span, const T &value0, const T &value1)
Checks if a read-only span contains any of two values.
Definition: memory_extensions.h:661
ReadOnlySpan< T > Trim(const ReadOnlySpan< T > &span, T trimElement)
Trims specified element from both ends of a typed span.
Definition: memory_extensions.h:2400
void Sort(const Span< T > &span, const SharedPtr< TComparer > &comparer)
Sorts a Span using a custom comparer.
Definition: memory_extensions.h:2204
int32_t CompareTo(const ReadOnlySpan< char16_t > &span, const ReadOnlySpan< char16_t > &other, StringComparison comparisonType)
Compares two character spans with specified string comparison rules.
bool ContainsAnyExcept(const ReadOnlySpan< T > &span, const T &value0, const T &value1, const T &value2)
Checks if a read-only span contains any element except three specified values.
Definition: memory_extensions.h:741
int32_t LastIndexOf(const ReadOnlySpan< char16_t > &span, const ReadOnlySpan< char16_t > &value, StringComparison comparisonType)
Finds the last occurrence of a value within a span using specified string comparison.
int32_t Count(const ReadOnlySpan< T > &span, const T &value)
Counts occurrences of a value in a read-only span.
Definition: memory_extensions.h:964
int32_t ToUpper(const ReadOnlySpan< char16_t > &source, Span< char16_t > &destination, const SharedPtr< Globalization::CultureInfo > &culture)
Converts characters to uppercase using specified culture.
ReadOnlySpan< T > TrimStart(const ReadOnlySpan< T > &span, const T &trimElement)
Trims specified element from the start of a typed span.
Definition: memory_extensions.h:2636
int32_t IndexOfAnyInRange(const ReadOnlySpan< T > &span, const T &lowInclusive, const T &highInclusive)
Finds the index of the first element that is within the specified range in a ReadOnlySpan<T>
Definition: memory_extensions.h:1499
bool IsWhiteSpace(const ReadOnlySpan< char16_t > &span)
Checks if the entire span consists only of whitespace characters.
bool EndsWith(const ReadOnlySpan< char16_t > &span, const ReadOnlySpan< char16_t > &value, StringComparison comparisonType)
Determines if a ReadOnlySpan<char16_t> ends with the specified value using StringComparison.
int32_t ToLowerInvariant(const ReadOnlySpan< char16_t > &source, Span< char16_t > &destination)
Converts characters to lowercase using invariant culture.
Definition: db_command.h:9
std::enable_if_t<!std::is_floating_point< TA >::value &&!std::is_floating_point< TB >::value, int > Compare(const TA &a, const TB &b)
Compares two values.
Definition: primitive_types.h:113
StringComparison
Defines string comparison style.
Definition: string_comparison.h:13