/// <summary> /// Initializes a new instance of the PersistentDictionaryLinqKeyEnumerable class. /// </summary> /// <param name="dict">The dictionary to enumerate.</param> /// <param name="expression">The expression describing the range of keys to return.</param> /// <param name="predicate">Predicate to apply to the return values.</param> /// <param name="isReversed"> /// A value that controls whether enumerators produced by this enumerable should be reversed. /// </param> public PersistentDictionaryLinqKeyEnumerable( PersistentDictionary <TKey, TValue> dict, Expression <Predicate <TKey> > expression, Predicate <TKey> predicate, bool isReversed) { this.dictionary = dict; this.expression = expression; this.predicate = predicate; this.isReversed = isReversed; }
/// <summary> /// Initializes a new instance of the /// <see cref="PersistentDictionaryReverseEnumerator{TKey,TValue,TReturn}"/> class. /// </summary> /// <param name="dictionary">The dictionary to enumerate.</param> /// <param name="range">The range to enumerate.</param> /// <param name="getter">A function that gets the value from a cursor.</param> /// <param name="predicate">The predicate to filter items with.</param> public PersistentDictionaryReverseEnumerator( PersistentDictionary <TKey, TValue> dictionary, KeyRange <TKey> range, Func <PersistentDictionaryCursor <TKey, TValue>, TReturn> getter, Predicate <TReturn> predicate) { this.dictionary = dictionary; this.range = range; this.getter = getter; this.predicate = predicate; }
/// <summary> /// Initializes a new instance of the PersistentDictionaryCollection class. /// </summary> /// <param name="dictionary"> /// The dictionary being enumerated to provide the collection. /// </param> protected PersistentDictionaryCollection(PersistentDictionary <TKey, TValue> dictionary) { this.dictionary = dictionary; }
/// <summary> /// Initializes a new instance of the PersistentDictionaryValueCollection class. /// </summary> /// <param name="dictionary">The dictionary containing the values.</param> public PersistentDictionaryValueCollection(PersistentDictionary <TKey, TValue> dictionary) : base(dictionary) { }
/// <summary> /// Returns a number that represents how many elements in the dictionary satisfy a condition. /// </summary> /// <typeparam name="TKey">The type of the dictionary's keys.</typeparam> /// <typeparam name="TValue">The type of the dictionary's values.</typeparam> /// <param name="source">The dictionary.</param> /// <param name="expression">A function to test each element for a condition.</param> /// <returns>The number of elements that satisfy the condition.</returns> /// <remarks> /// This method cannot be defined on the PersistentDictonary because it conflicts /// with the Count property. /// </remarks> public static int Count <TKey, TValue>( this PersistentDictionary <TKey, TValue> source, Expression <Predicate <KeyValuePair <TKey, TValue> > > expression) where TKey : IComparable <TKey> { return(source.Where(expression).Count()); }