-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTree.cs
More file actions
31 lines (26 loc) · 710 Bytes
/
Tree.cs
File metadata and controls
31 lines (26 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace TestAssembly.Collections
{
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Tree : ICanAdd<Branch>, IEnumerable<Leaf>
{
readonly List<Branch> items = new List<Branch>();
public void Add(Branch item)
{
items.Add(item);
}
public IEnumerator<Branch> GetEnumerator()
{
return items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator<Leaf> IEnumerable<Leaf>.GetEnumerator()
{
return items.SelectMany(i => i).GetEnumerator();
}
}
}