public void TestAddRange() { IImmutableDictionary <int, int> dictionary = CreateDictionary <int, int>(); Assert.Empty(dictionary); Assert.Same(dictionary, dictionary.AddRange(Enumerable.Empty <KeyValuePair <int, int> >())); Assert.Throws <ArgumentNullException>("items", () => dictionary.AddRange(null)); dictionary = dictionary.AddRange(Enumerable.Range(0, 10).Select(x => new KeyValuePair <int, int>(x, x + 1))); Assert.Equal( new[] { new KeyValuePair <int, int>(0, 1), new KeyValuePair <int, int>(1, 2), new KeyValuePair <int, int>(2, 3), new KeyValuePair <int, int>(3, 4), new KeyValuePair <int, int>(4, 5), new KeyValuePair <int, int>(5, 6), new KeyValuePair <int, int>(6, 7), new KeyValuePair <int, int>(7, 8), new KeyValuePair <int, int>(8, 9), new KeyValuePair <int, int>(9, 10), }, dictionary); }
protected void AddRemoveEnumerableTestHelper(IImmutableDictionary<int, int> empty) { Assert.NotNull(empty); Assert.Same(empty, empty.RemoveRange(Enumerable.Empty<int>())); Assert.Same(empty, empty.AddRange(Enumerable.Empty<KeyValuePair<int, int>>())); var list = new List<KeyValuePair<int, int>> { new KeyValuePair<int, int>(3, 5), new KeyValuePair<int, int>(8, 10) }; var nonEmpty = empty.AddRange(list); this.VerifyAvlTreeState(nonEmpty); var halfRemoved = nonEmpty.RemoveRange(Enumerable.Range(1, 5)); Assert.Equal(1, halfRemoved.Count); Assert.True(halfRemoved.ContainsKey(8)); this.VerifyAvlTreeState(halfRemoved); }
protected void AddRemoveEnumerableTestHelper(IImmutableDictionary <int, int> empty) { Contract.Requires(empty != null); Assert.Same(empty, empty.RemoveRange(Enumerable.Empty <int>())); Assert.Same(empty, empty.AddRange(Enumerable.Empty <KeyValuePair <int, int> >())); var list = new List <KeyValuePair <int, int> > { new KeyValuePair <int, int>(3, 5), new KeyValuePair <int, int>(8, 10) }; var nonEmpty = empty.AddRange(list); var halfRemoved = nonEmpty.RemoveRange(Enumerable.Range(1, 5)); Assert.Equal(1, halfRemoved.Count); Assert.True(halfRemoved.ContainsKey(8)); }
public TaintHandlerTaintSet(Dictionary <Variable, VariableTaint> variableTaints) { Preconditions.NotNull(variableTaints, "variableTaints"); Taint = ImmutableDictionary <Variable, VariableTaint> .Empty; Taint = Taint.AddRange(variableTaints); }
public static IImmutableDictionary <HashValue, T> AddRange <T>(this IImmutableDictionary <HashValue, T> dictionary, IEnumerable <T> values) where T : ISigned { var keyValues = values.ToKeyValues(v => v.Signature); return(dictionary.AddRange(keyValues)); }
/// <summary> /// Adds element classes to this set. /// </summary> public ElementClassSet Add(ElementClassSet classSet) { if (ConditionsByClassName.Keys.Intersect(classSet.ConditionsByClassName.Keys).Any()) { throw new ApplicationException("At least one class exists in both sets."); } return(new ElementClassSet(ConditionsByClassName.AddRange(classSet.ConditionsByClassName))); }
protected void AddExistingKeySameValueTestHelper <TKey, TValue>(IImmutableDictionary <TKey, TValue> map, TKey key, TValue value1, TValue value2) { Assert.NotNull(map); Assert.NotNull(key); Assert.True(GetValueComparer(map).Equals(value1, value2)); map = map.Add(key, value1); Assert.Same(map, map.Add(key, value2)); Assert.Same(map, map.AddRange(new[] { new KeyValuePair <TKey, TValue>(key, value2) })); }
protected void AddExistingKeySameValueTestHelper <TKey, TValue>(IImmutableDictionary <TKey, TValue> map, TKey key, TValue value1, TValue value2) { Contract.Requires(map != null); Contract.Requires(key != null); Contract.Requires(GetValueComparer(map).Equals(value1, value2)); map = map.Add(key, value1); Assert.Same(map, map.Add(key, value2)); Assert.Same(map, map.AddRange(new[] { new KeyValuePair <TKey, TValue>(key, value2) })); }
private IImmutableDictionary <string, ITypeSpecBuilder> IntrospectSystemTypes(Type[] systemTypes, IImmutableDictionary <string, ITypeSpecBuilder> specDictionary) { var placeholders = GetPlaceholders(systemTypes, ClassStrategy); var pending = specDictionary.Where(i => i.Value.IsPendingIntrospection).Select(i => i.Value.Type); var toIntrospect = placeholders.Select(kvp => kvp.Value.Type).Union(pending).ToArray(); return(placeholders.Any() ? IntrospectTypes(toIntrospect, specDictionary.AddRange(placeholders)) : specDictionary); }
public static IImmutableDictionary <T, TValue> AddNotNullRange <T, TValue>(this IImmutableDictionary <T, TValue> dictionary, IEnumerable <KeyValuePair <T, TValue> > items) { if (items == null) { return(dictionary); } if (ReferenceEquals(dictionary, ImmutableDictionary <T, TValue> .Empty)) { return(items.ToImmutableDictionary()); } return(dictionary.AddRange(items)); }
/// <summary> /// Adds element classes to this set. /// </summary> public ElementClassSet Add(ElementClassSet classSet) { if ( JsModificationStatementAdderAndInclusionPredicatePairsByClassName.Keys.Intersect( classSet.JsModificationStatementAdderAndInclusionPredicatePairsByClassName.Keys).Any()) { throw new ApplicationException("At least one class exists in both sets."); } return (new ElementClassSet( JsModificationStatementAdderAndInclusionPredicatePairsByClassName.AddRange(classSet.JsModificationStatementAdderAndInclusionPredicatePairsByClassName))); }
public static IImmutableDictionary <string, IType> Merge(this IImmutableDictionary <string, IType> left, IImmutableDictionary <string, IType> right) { // check to see that substitutions have the same value for each key // AddRange does the same check but this gives a more informative error message foreach (var lkv in left) { if (right.TryGetValue(lkv.Key, out var rv) && lkv.Value != rv) { throw new Exception($"Cannot merge substitutions, values at variable '{lkv.Key}' are not equal: {lkv.Value}, {rv}"); } } return(left.AddRange(right)); }
public IImmutableDictionary <Address, object> AddRange(IEnumerable <KeyValuePair <Address, object> > pairs) { return(new AddressStateMap(_impl.AddRange(pairs))); }
IImmutableDictionary <MemberInfo, MemberMetadata> IImmutableDictionary <MemberInfo, MemberMetadata> .AddRange(IEnumerable <KeyValuePair <MemberInfo, MemberMetadata> > pairs) { return(_metadata.AddRange(pairs)); }
public static IImmutableDictionary <T, TValue> AddNotNullRange <T, TValue>(this IImmutableDictionary <T, TValue> dictionary, IEnumerable <KeyValuePair <T, TValue> > items) { return(items != null?dictionary.AddRange(items) : dictionary); }
public static IImmutableDictionary <K, V> addRange <K, V>(IImmutableDictionary <K, V> map, IEnumerable <KeyValuePair <K, V> > keyValues) => map.AddRange(keyValues);
public IImmutableUniqueDictionary <K, V> AddRange(IEnumerable <KeyValuePair <K, V> > pairs) { return(new ImmutableUniqueDictionary <K, V>(_dictionary.AddRange(pairs))); }
public IImmutableDictionary <K, V> AddRange(IEnumerable <KeyValuePair <K, V> > pairs) => CreateNew(Immutable.AddRange(pairs));
public IImmutableDictionary <PackageIdentity, IImmutableList <PackageIdentity> > AddRange( IEnumerable <KeyValuePair <PackageIdentity, IImmutableList <PackageIdentity> > > pairs) => _dictionary.AddRange(pairs);