Table of Contents

Class Utilities

Namespace
Stride.Core
Assembly
Stride.Core.dll

Provides a set of static utility methods for collection operations, and general-purpose helpers.

public static class Utilities
Inheritance
object
Utilities

Methods

Compare<TKey, TValue>(SortedList<TKey, TValue>, SortedList<TKey, TValue>)

Compares two collection, element by elements.

public static bool Compare<TKey, TValue>(SortedList<TKey, TValue> first, SortedList<TKey, TValue> second)

Parameters

first SortedList<TKey, TValue>

The collection to compare from.

second SortedList<TKey, TValue>

The colllection to compare to.

Returns

bool

True if lists are identical (but not necessarily in the same order). False otherwise.

Type Parameters

TKey
TValue

Remarks

Concrete SortedList is favored over interface to avoid enumerator object allocation.

Compare<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)

Compares two collection, element by elements.

public static bool Compare<TKey, TValue>(IDictionary<TKey, TValue> first, IDictionary<TKey, TValue> second)

Parameters

first IDictionary<TKey, TValue>

The collection to compare from.

second IDictionary<TKey, TValue>

The colllection to compare to.

Returns

bool

True if lists are identical (but no necessarely of the same time). False otherwise.

Type Parameters

TKey
TValue

ConvertRawToTimestamp(long)

Converts a Stopwatch raw time to a TimeSpan.

public static TimeSpan ConvertRawToTimestamp(long delta)

Parameters

delta long

The delta.

Returns

TimeSpan

The TimeSpan.

Dispose<T>(ref T?)

Disposes an IDisposable object if not null, and sets it to null.

public static void Dispose<T>(ref T? disposable) where T : class, IDisposable

Parameters

disposable T

The disposable object to dispose.

Type Parameters

T

GetHashCode(IDictionary)

Computes a hashcode for a dictionary.

public static int GetHashCode(IDictionary dict)

Parameters

dict IDictionary

Returns

int

Hashcode for the list.

GetHashCode(IEnumerable)

Computes a hashcode for an enumeration

public static int GetHashCode(IEnumerable it)

Parameters

it IEnumerable

An enumerator.

Returns

int

Hashcode for the list.

GetHashCode(IEnumerator)

Computes a hashcode for an enumeration

public static int GetHashCode(IEnumerator it)

Parameters

it IEnumerator

An enumerator.

Returns

int

Hashcode for the list.

IterateTree<T>(T, Func<T, IEnumerable<T>>)

Linq assisted full tree iteration and collection in a single line. Warning, could be slow.

public static IEnumerable<T> IterateTree<T>(T root, Func<T, IEnumerable<T>> childrenF)

Parameters

root T

The root item

childrenF Func<T, IEnumerable<T>>

The function to retrieve a child

Returns

IEnumerable<T>

Type Parameters

T

The type to iterate.

ReadStream(Stream)

Read stream to a byte[] buffer

[Obsolete("Allocates. Read into the destination.")]
public static byte[] ReadStream(Stream stream)

Parameters

stream Stream

input stream

Returns

byte[]

a byte[] buffer