public static T Peek <T>(this IPop <T> c) { bool isEmpty; T next = c.TryPeek(out isEmpty); if (isEmpty) { throw new InvalidOperationException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType()))); } return(next); }
public static T Pop <T>(this ITryPop <T> c) { bool isEmpty; T next = c.TryPop(out isEmpty); if (isEmpty) { throw new EmptySequenceException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType()))); } return(next); }
internal static string VisualizerName(string name) { string typeName = MemoizedTypeName <T> .GenericName(); if (!string.IsNullOrEmpty(name)) { return(string.Format("{0}: {1}", name, typeName)); } else { return(typeName); } }
public ComputedList(Func <IEnumerable <T> > computeCollection) { _computeCollection = computeCollection; _computedSentry = new NamedComputed(MemoizedTypeName <ComputedList <T> > .GenericName(), delegate { using (var bin = new RecycleBin <T>(_list)) { _list.Clear(); foreach (T item in computeCollection()) { _list.Add(bin.Extract(item)); } } }); }
public DependentDictionary(Func <IEnumerable <KeyValuePair <TKey, TValue> > > updateCollection, bool recycleValues) { _computeCollection = updateCollection; _dependentSentry = new NamedDependent(MemoizedTypeName <DependentDictionary <TKey, TValue> > .GenericName(), Update); _recycleValues = recycleValues; }