add ToQueue and ToStack

This commit is contained in:
ig 2023-04-06 14:31:19 +02:00
parent 65dd23bd8e
commit ba54f9e325
1 changed files with 16 additions and 0 deletions

View File

@ -68,7 +68,23 @@ public static class EnumerableUtils
// } // }
public static Queue<T> ToQueue<T>(this IEnumerable<T> ts)
{
var q = new Queue<T>();
foreach (var t in ts)
q.Enqueue(t);
return q;
}
public static Stack<T> ToStack<T>(this IEnumerable<T> ts)
{
var s = new Stack<T>();
foreach (var t in ts)
s.Push(t);
return s;
}
public static async IAsyncEnumerable<R> public static async IAsyncEnumerable<R>
SelectManyAsync<T, R>(this IEnumerable<T> ts, Func<T, Task<IEnumerable<R>>> func) SelectManyAsync<T, R>(this IEnumerable<T> ts, Func<T, Task<IEnumerable<R>>> func)