Example #1
0
 public EquatableDictionary(ImmutableDictionary <TKey, TValue> dictionary)
 {
     this.dictionary = dictionary;
     this.hashCode   = dictionary.Aggregate(
         "EquatableDictionary".GetHashCode(),
         (h, kvp) =>
         h ^ kvp.Key.GetHashCode() ^ kvp.Value.GetHashCode());
 }
Example #2
0
 public static ImmutableDictionary <A, B> Merge <A, B>(
     this ImmutableDictionary <A, B> first,
     ImmutableDictionary <A, B> second,
     Func <B, B, B> resolve)
 {
     return(second.Aggregate(first, (fst, kvp) => fst.SetItem(
                                 kvp.Key,
                                 fst.ContainsKey(kvp.Key) ? resolve(fst[kvp.Key], kvp.Value) : kvp.Value
                                 )));
 }
 public TestLearnStateBuilder WithSentence(ImmutableDictionary <string, int> sentences)
 {
     _state = sentences.Aggregate(_state, (acc, x) => _learner.Learn(acc, new Sentence(x.Key, x.Value >= 0 ? WordCategory.Positive : WordCategory.Negative)));
     return(this);
 }
Example #4
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="state">TBD</param>
 /// <param name="delta">TBD</param>
 internal GCounter(ImmutableDictionary <UniqueAddress, ulong> state, GCounter delta = null)
 {
     _syncRoot = delta;
     State     = state;
     Value     = State.Aggregate(Zero, (v, acc) => v + acc.Value);
 }
Example #5
0
 public static ImmutableDictionary <string, Reaction> Substitute(
     this ImmutableDictionary <string, Reaction> reactions)
 {
     return(reactions.Aggregate(reactions,
                                (accu, current) => accu.SetItem(current.Key, Subst(current.Value, reactions))));
 }