Show / Hide Table of Contents

Class NativeMemoryExtensions

Provides extensions for NativeMemory type.

Inheritance
object
NativeMemoryExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.dll
Syntax
public static class NativeMemoryExtensions

Methods

View Source

AsBytes<T>(T*)

Converts contiguous memory identified by the specified pointer into Span<T>.

Declaration
[CLSCompliant(false)]
public static Span<byte> AsBytes<T>(T* pointer) where T : unmanaged, allows ref struct
Parameters
Type Name Description
T* pointer

The typed pointer.

Returns
Type Description
Span<byte>

The span of contiguous memory.

Type Parameters
Name Description
T

Blittable type.

View Source

Compare(void*, void*, nuint)

Bitwise comparison of two memory blocks.

Declaration
[CLSCompliant(false)]
public static int Compare(void* first, void* second, nuint length)
Parameters
Type Name Description
void* first

The pointer to the first memory block.

void* second

The pointer to the second memory block.

nuint length

The length of the first and second memory blocks.

Returns
Type Description
int

Comparison result which has the semantics as return type of CompareTo(object).

View Source

CopyUnaligned<T>(T*, T*)

Copies one value into another assuming unaligned memory access.

Declaration
[CLSCompliant(false)]
public static void CopyUnaligned<T>(T* input, T* output) where T : unmanaged
Parameters
Type Name Description
T* input

The reference to the source location.

T* output

The reference to the destination location.

Type Parameters
Name Description
T

The value type to copy.

View Source

Copy<T>(T*, T*)

Copies one value into another.

Declaration
[CLSCompliant(false)]
public static void Copy<T>(T* input, T* output) where T : unmanaged
Parameters
Type Name Description
T* input

The reference to the source location.

T* output

The reference to the destination location.

Type Parameters
Name Description
T

The value type to copy.

View Source

Equals(void*, void*, nuint)

Computes equality between two blocks of memory.

Declaration
[CLSCompliant(false)]
public static bool Equals(void* first, void* second, nuint length)
Parameters
Type Name Description
void* first

A pointer to the first memory block.

void* second

A pointer to the second memory block.

nuint length

Length of first and second memory blocks, in bytes.

Returns
Type Description
bool

true, if both memory blocks have the same data; otherwise, false.

View Source

PointerHashCode(void*)

Computes transient hash code of the specified pointer.

Declaration
[CLSCompliant(false)]
public static int PointerHashCode(void* pointer)
Parameters
Type Name Description
void* pointer

The pointer value.

Returns
Type Description
int

The hash code of the pointer.

View Source

Swap<T>(T*, T*)

Swaps two values.

Declaration
[CLSCompliant(false)]
public static void Swap<T>(T* first, T* second) where T : unmanaged
Parameters
Type Name Description
T* first

The first value to be replaced with second.

T* second

The second value to be replaced with first.

Type Parameters
Name Description
T

The type of the value.

  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾