Table of Contents

Class StdVector<T>

Namespace
OpenCvSharp.Internal.Vectors
Assembly
OpenCvSharp.dll

Generic wrapper over a native std::vector whose element type is an unmanaged (blittable) value type. A single StdVector<T> replaces the former hand-written VectorOfXxx classes.

public class StdVector<T> : CvObject, IStdVector<T>, IDisposable where T : unmanaged

Type Parameters

T

Unmanaged element type matching the native std::vector element.

Inheritance
StdVector<T>
Implements
Inherited Members

Remarks

The element-specific native entry points are selected by typeof(T) comparisons. Because T is always a value type, the JIT specializes each closed generic (e.g. StdVector<int>) and folds those comparisons into compile-time constants, so the dispatch collapses to a single direct P/Invoke call with no delegate indirection and no per-call branching.

Constructors

StdVector()

Creates an empty vector.

public StdVector()

StdVector(IEnumerable<T>)

Creates a vector populated from data.

public StdVector(IEnumerable<T> data)

Parameters

data IEnumerable<T>

StdVector(nint)

Wraps an existing native std::vector pointer.

protected StdVector(nint ptr)

Parameters

ptr nint

StdVector(nuint)

Creates a vector pre-sized to size default-initialized elements.

public StdVector(nuint size)

Parameters

size nuint

Properties

ElemPtr

&vector[0]

public nint ElemPtr { get; }

Property Value

nint

Size

vector.size()

public int Size { get; }

Property Value

int

Methods

DisposeUnmanaged()

Releases unmanaged resources

protected override void DisposeUnmanaged()

ToArray()

Converts std::vector to managed array

public virtual T[] ToArray()

Returns

T[]

ToArray<TResult>()

Converts std::vector to a managed array, reinterpreting each element as TResult (which must have the same byte size as T).

public TResult[] ToArray<TResult>() where TResult : unmanaged

Returns

TResult[]

Type Parameters

TResult