2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

高速なLINQ互換パッケージ ZLinq

Posted at

参考

この記事は、以下の動画を参考にしています。
詳しくは、動画をご覧ください。

NuGet Gallery

プロジェクトのサイト

作者による解説

ZLinqの特徴

ヒープを使わない、LINQ互換のメソッドを提供するNuGetパッケージ。
ヒープを使わないので、.NETオリジナルのLINQに比べて高速である。

また、.NETオリジナルのLINQにはない、Span<T>に対するメソッドも提供されている。

ZLinqの使用手順

  1. ZLinqをプロジェクトにインストールする
  2. コレクションに対してAsValueEnumerableメソッドを呼ぶ
  3. その結果に対して、LINQ(互換)のメソッドを呼ぶ
ZLinq
using ZLinq;

var sum = numbers
    .AsValueEnumerable()
    .Where(x => x % 2 == 0)
    .Select(x => x * 3)
    .Sum();
LINQ to Span
using ZLinq;

Span<int> span = [1, 2, 3, 4, 5];
var sum = span
    .AsValueEnumerable()
    .Where(x => x % 2 == 0)
    .Select(x => x * 3)
    .Sum();
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?