EnumerableGrouping.cs 871 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace System.Linq
  6. {
  7. class EnumerableGrouping<TKey, TElement> : IGrouping<TKey, TElement>
  8. {
  9. List<TElement> elements = new List<TElement>();
  10. public EnumerableGrouping(TKey key)
  11. {
  12. Key = key;
  13. }
  14. public void Add(TElement element)
  15. {
  16. elements.Add(element);
  17. }
  18. public TKey Key { get; private set; }
  19. public IEnumerator<TElement> GetEnumerator()
  20. {
  21. return elements.GetEnumerator();
  22. }
  23. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
  24. {
  25. return this.GetEnumerator();
  26. }
  27. }
  28. }