Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Sources/HonkPerf.NET.RefLinq/Enumerators/HashSetEnumerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace HonkPerf.NET.RefLinq.Enumerators;

public struct HashSetEnumerator<T> : IRefEnumerable<T>
{
private T curr;
private HashSet<T>.Enumerator ie;

public HashSetEnumerator(HashSet<T> set)
{
ie = set.GetEnumerator();
curr = default;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool MoveNext()
{
bool t = ie.MoveNext();
curr = ie.Current;
if(!t)
ie.Dispose();
return t;
}

public T Current => curr;
}
2 changes: 2 additions & 0 deletions Sources/HonkPerf.NET.RefLinq/ToRefLinq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static RefLinqEnumerable<T, IReadOnlyListEnumerator<T>> ToRefLinq<T>(this
=> new(new(c));
public static RefLinqEnumerable<T, ArrayEnumerator<T>> ToRefLinq<T>(this T[] c)
=> new(new(c));
public static RefLinqEnumerable<T, HashSetEnumerator<T>> ToRefLinq<T>(this HashSet<T> c)
=> new(new(c));

public unsafe static RefLinqEnumerable<T, FixedReadOnlySpanEnumerator<T>> ToRefLinq<T>(this FixedReadOnlySpan<T> c)
where T : unmanaged
Expand Down