Table of Contents

Struct UnmanagedMemoryBlock<T>

Namespace
NumSharp.Backends.Unmanaged
Assembly
NumSharp.dll
public struct UnmanagedMemoryBlock<T> : IUnmanagedMemoryBlock, IMemoryBlock<T>, IMemoryBlock, IEnumerable<T>, IEnumerable, IEquatable<UnmanagedMemoryBlock<T>>, ICloneable where T : unmanaged

Type Parameters

T
Implements
Inherited Members
Extension Methods

Constructors

UnmanagedMemoryBlock(long)

public UnmanagedMemoryBlock(long count)

Parameters

count long

The length in objects of T and not in bytes.

Remarks

Does claim ownership since allocation is publicly.

UnmanagedMemoryBlock(long, T)

public UnmanagedMemoryBlock(long count, T fill)

Parameters

count long

The length in objects of T and not in bytes.

fill T

UnmanagedMemoryBlock(GCHandle, long)

Construct with externally allocated memory settings this memory block as owner.

public UnmanagedMemoryBlock(GCHandle handle, long count)

Parameters

handle GCHandle
count long

The length in objects of T and not in bytes.

Remarks

Does claim ownership.

UnmanagedMemoryBlock(GCHandle, long, Action)

Construct with externally allocated memory and a custom dispose function.

public UnmanagedMemoryBlock(GCHandle handle, long count, Action dispose)

Parameters

handle GCHandle
count long

The length in objects of T and not in bytes.

dispose Action

Remarks

Does claim ownership.

UnmanagedMemoryBlock(T*, long)

Construct as a wrapper around pointer and given length without claiming ownership.

public UnmanagedMemoryBlock(T* ptr, long count)

Parameters

ptr T*
count long

The length in objects of T and not in bytes.

Remarks

Does claim ownership.

UnmanagedMemoryBlock(T*, long, Action)

Construct with externally allocated memory and a custom dispose function.

public UnmanagedMemoryBlock(T* start, long count, Action dispose)

Parameters

start T*
count long

The length in objects of T and not in bytes.

dispose Action

Remarks

Does claim ownership.

Fields

Address

public readonly T* Address

Field Value

T*

BytesCount

public readonly long BytesCount

Field Value

long

Count

public readonly long Count

Field Value

long

Properties

this[int]

public T this[int index] { get; set; }

Parameters

index int

Property Value

T

Methods

Clone()

Performs a copy to this memory block.

public UnmanagedMemoryBlock<T> Clone()

Returns

UnmanagedMemoryBlock<T>

Contains(T)

public bool Contains(T item)

Parameters

item T

Returns

bool

Copy(UnmanagedMemoryBlock<T>)

public static UnmanagedMemoryBlock<T> Copy(UnmanagedMemoryBlock<T> source)

Parameters

source UnmanagedMemoryBlock<T>

Returns

UnmanagedMemoryBlock<T>

Copy(nint, int)

public static UnmanagedMemoryBlock<T> Copy(nint address, int count)

Parameters

address nint
count int

How many T to copy, not how many bytes.

Returns

UnmanagedMemoryBlock<T>

Copy(void*, int)

public static UnmanagedMemoryBlock<T> Copy(void* address, int count)

Parameters

address void*

The address of the first T

count int

How many T to copy, not how many bytes.

Returns

UnmanagedMemoryBlock<T>

Copy(T*, int)

public static UnmanagedMemoryBlock<T> Copy(T* address, int count)

Parameters

address T*

The address of the first T

count int

How many T to copy, not how many bytes.

Returns

UnmanagedMemoryBlock<T>

CopyTo(UnmanagedMemoryBlock<T>, long)

public void CopyTo(UnmanagedMemoryBlock<T> memoryBlock, long arrayIndex)

Parameters

memoryBlock UnmanagedMemoryBlock<T>
arrayIndex long

CopyTo(Array, int)

Copies the elements of the ICollection to an Array, starting at a particular Array index.

public void CopyTo(Array array, int arrayIndex)

Parameters

array Array

The one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than zero.

ArgumentException

array is multidimensional.-or- The number of elements in the source ICollection is greater than the available space from arrayIndex to the end of the destination array.-or-The type of the source ICollection cannot be cast automatically to the type of the destination array.

CopyTo(T*, long, long)

public void CopyTo(T* array, long arrayIndex, long lengthToCopy)

Parameters

array T*
arrayIndex long
lengthToCopy long

CopyTo(T[], int)

public void CopyTo(T[] array, int arrayIndex)

Parameters

array T[]
arrayIndex int

Equals(UnmanagedMemoryBlock<T>)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(UnmanagedMemoryBlock<T> other)

Parameters

other UnmanagedMemoryBlock<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Fill(T)

Fills the contents of this span with the given value.

public void Fill(T value)

Parameters

value T

Fill(T, long, long)

Fills the contents of this span with the given value.

public void Fill(T value, long offset, long count)

Parameters

value T
offset long
count long

Free()

public void Free()

FromArray(T[,,,,,,,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,] arr)

Parameters

arr T[,,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,] arr)

Parameters

arr T[,,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,] arr)

Parameters

arr T[,,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,,] arr, bool copy)

Parameters

arr T[,,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,] arr)

Parameters

arr T[,,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,,] arr, bool copy)

Parameters

arr T[,,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,] arr)

Parameters

arr T[,,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,,] arr, bool copy)

Parameters

arr T[,,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,,] arr)

Parameters

arr T[,,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,,] arr, bool copy)

Parameters

arr T[,,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,])

public static UnmanagedMemoryBlock<T> FromArray(T[,,] arr)

Parameters

arr T[,,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,,] arr, bool copy)

Parameters

arr T[,,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,])

public static UnmanagedMemoryBlock<T> FromArray(T[,] arr)

Parameters

arr T[,]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[,], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[,] arr, bool copy)

Parameters

arr T[,]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromArray(T[])

public static UnmanagedMemoryBlock<T> FromArray(T[] arr)

Parameters

arr T[]

Returns

UnmanagedMemoryBlock<T>

FromArray(T[], bool)

public static UnmanagedMemoryBlock<T> FromArray(T[] arr, bool copy)

Parameters

arr T[]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromBuffer(byte[])

public static UnmanagedMemoryBlock<T> FromBuffer(byte[] arr)

Parameters

arr byte[]

Returns

UnmanagedMemoryBlock<T>

FromBuffer(byte[], bool)

public static UnmanagedMemoryBlock<T> FromBuffer(byte[] arr, bool copy)

Parameters

arr byte[]
copy bool

Returns

UnmanagedMemoryBlock<T>

FromPool(StackedMemoryPool)

public static UnmanagedMemoryBlock<T> FromPool(StackedMemoryPool manager)

Parameters

manager StackedMemoryPool

Returns

UnmanagedMemoryBlock<T>

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

An enumerator that can be used to iterate through the collection.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetIndex(int)

public T GetIndex(int index)

Parameters

index int

Returns

T

GetIndex(long)

public T GetIndex(long index)

Parameters

index long

Returns

T

GetRefTo(int)

public ref T GetRefTo(int index)

Parameters

index int

Returns

T

GetRefTo(long)

public ref T GetRefTo(long index)

Parameters

index long

Returns

T

Reallocate(long, bool)

public void Reallocate(long length, bool copyOldValues = false)

Parameters

length long
copyOldValues bool

Reallocate(long, T, bool)

public void Reallocate(long length, T fill, bool copyOldValues = false)

Parameters

length long
fill T
copyOldValues bool

SetIndex(int, T)

public void SetIndex(int index, T value)

Parameters

index int
value T

SetIndex(int, ref T)

public void SetIndex(int index, ref T value)

Parameters

index int
value T

SetIndex(long, T)

public void SetIndex(long index, T value)

Parameters

index long
value T

SetIndex(long, ref T)

public void SetIndex(long index, ref T value)

Parameters

index long
value T

Operators

operator ==(UnmanagedMemoryBlock<T>, UnmanagedMemoryBlock<T>)

Returns a value that indicates whether the values of two NumSharp.Backends.Unmanaged.UnmanagedArray`1 objects are equal.

public static bool operator ==(UnmanagedMemoryBlock<T> left, UnmanagedMemoryBlock<T> right)

Parameters

left UnmanagedMemoryBlock<T>

The first value to compare.

right UnmanagedMemoryBlock<T>

The second value to compare.

Returns

bool

true if the left and right parameters have the same value; otherwise, false.

operator !=(UnmanagedMemoryBlock<T>, UnmanagedMemoryBlock<T>)

Returns a value that indicates whether two NumSharp.Backends.Unmanaged.UnmanagedArray`1 objects have different values.

public static bool operator !=(UnmanagedMemoryBlock<T> left, UnmanagedMemoryBlock<T> right)

Parameters

left UnmanagedMemoryBlock<T>

The first value to compare.

right UnmanagedMemoryBlock<T>

The second value to compare.

Returns

bool

true if left and right are not equal; otherwise, false.