/Blinq

Burst Compatible Linq Implementations

Primary LanguageC#MIT LicenseMIT

Blinq

Burst Compatible, deferred, stack-allocated LINQ extensions for NativeArray.

Installation

This project can be installed as a UPM package. The easiest way to install it right now is using the OpenUPM.

Currently, support for the Github Package Registry is broken. See this thread here for more information.

Differences with Linq

Delegates

The Burst compiler doesn't support C# delegates. To get around this issue, Blinq requires you to create structs that implement the IFunc interface. The Burst.Delegates project has other useful tools to help you implement the IFunc interface.

/*--- Using Linq ---*/
var selected = myArray.Select(val => val.Item);

/*--- Using Blinq ---*/

// Must define a method that can be used as FunctionPointer
[BurstCompile]
public static int SelectItem(MyVal val) => val.Item;

public static readonly BurstFunc<MyVal, int> SelectItemFunc = BustFunc<MyVal, int>.Compile(SelectItem);

// Now we can finally call ``Select``
var selected = myArray.Select(SelectItemFunc);