2022-12-02 15:03:34 +01:00

28 lines
551 B
C#

using System.Collections;
namespace Connected.Expressions.Translation;
internal sealed class Grouping<TKey, TElement> : IGrouping<TKey, TElement>
{
public Grouping(TKey key, IEnumerable<TElement> group)
{
Key = key;
Group = group;
}
public TKey Key { get; }
private IEnumerable<TElement> Group { get; set; }
public IEnumerator<TElement> GetEnumerator()
{
if (!(Group is List<TElement>))
Group = Group.ToList();
return Group.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return Group.GetEnumerator();
}
}