Class NativeMemoryExtensions
Provides extensions for NativeMemory type.
Inherited Members
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.dll
Syntax
public static class NativeMemoryExtensions
Methods
View SourceAsBytes<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. |
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). |
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. |
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. |
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. |
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. |
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 |
| T* | second | The second value to be replaced with |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |