1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System; 8 using System.Collections.Generic; 9 using System.Linq; 10 11 namespace Antmicro.Renode.Utilities.Collections 12 { 13 public sealed class LazyList<T> 14 { LazyList()15 public LazyList() 16 { 17 funcs = new List<Func<T>>(); 18 } 19 Add(Func<T> func)20 public void Add(Func<T> func) 21 { 22 funcs.Add(func); 23 } 24 ToList()25 public List<T> ToList() 26 { 27 return funcs.Select(x => x()).ToList(); 28 } 29 30 private readonly List<Func<T>> funcs; 31 } 32 } 33