IMPORTANT: Blinq is no longer being developed because of limitations to recursive generics. Instead, I recommend taking a look at the LinqGen project.
Burst Compatible, deferred, stack-allocated LINQ extensions for NativeArray
.
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.
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);