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
TUnmanaged element type matching the native
std::vectorelement.
- Inheritance
-
StdVector<T>
- Implements
-
IStdVector<T>
- 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
dataIEnumerable<T>
StdVector(nint)
Wraps an existing native std::vector pointer.
protected StdVector(nint ptr)
Parameters
ptrnint
StdVector(nuint)
Creates a vector pre-sized to size default-initialized elements.
public StdVector(nuint size)
Parameters
sizenuint
Properties
ElemPtr
&vector[0]
public nint ElemPtr { get; }
Property Value
Size
vector.size()
public int Size { get; }
Property Value
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