Struct IndexCollector
A growable buffer for collecting long indices, backed by NDArray storage. Replaces LongIndexBuffer - uses NumSharp's existing unmanaged memory infrastructure.
public struct IndexCollector
- Inherited Members
- Extension Methods
Remarks
Benefits over LongIndexBuffer:
- Uses NDArray's proven unmanaged storage
- No separate Dispose needed (NDArray handles cleanup)
- ToResult() returns the storage directly (no copy for final result)
- Integrates with NumSharp's memory management
Growth strategy:
- Doubles capacity below 1 billion elements
- 33% growth above 1 billion (matches Hashset/LongList pattern)
Constructors
IndexCollector(long)
Creates a new collector with the specified initial capacity.
public IndexCollector(long initialCapacity)
Parameters
initialCapacitylongInitial capacity (number of elements).
Properties
Count
Number of elements collected.
public long Count { get; }
Property Value
Data
Pointer to the underlying data.
public long* Data { get; }
Property Value
- long*
this[long]
Gets the value at the specified index.
public long this[long index] { get; }
Parameters
indexlong
Property Value
Methods
Add(long)
Adds a value, growing the storage if necessary.
public void Add(long value)
Parameters
valuelong
ToResult()
Returns the collected indices as an NDArray, trimmed to actual count.
public NDArray<long> ToResult()
Returns
Remarks
If count equals capacity, returns storage directly (no copy). Otherwise, creates a properly-sized copy.