public void Contains_Test() { Dictionary <int, string> _dictionary = new Dictionary <int, string> { { 1, "aabb" }, { 2, "bbcc" }, { 3, "ccdd" } }; ImmutableDictionary <int, string> _immutableDictionary = new ImmutableDictionary <int, string>(_dictionary); Assert.IsTrue(_immutableDictionary.Contains(new KeyValuePair <int, string>(1, "aabb"))); Assert.IsFalse(_immutableDictionary.Contains(new KeyValuePair <int, string>(1, "aabbcc"))); }
public T Get <T> (string property, T defaultValue) { if (!defaultValues.Contains(new KeyValuePair <string, object> (property, defaultValue))) { defaultValues = defaultValues.SetItem(property, defaultValue); } object val; if (GetPropertyValue <T> (property, out val)) { return(Convert <T> (val)); } properties = properties.SetItem(property, defaultValue); return(defaultValue); }
public PakiraTree ReplaceLeaf(PakiraLeaf leaf, PakiraTree pakiraTree) { IPakiraNode leafParent = GetParentNode(leaf); // The current pakira tree only has a leaf as root if (leafParent == null) { leaf.ShouldBe(Root); return(pakiraTree); } else { ImmutableDictionary <IPakiraNode, IPakiraNode> updatedLeftNodes; ImmutableDictionary <IPakiraNode, IPakiraNode> updatedRightNodes; ImmutableDictionary <IPakiraNode, IPakiraNode> updatedParentNodes; if (leftNodes.Contains(leafParent, leaf)) { updatedLeftNodes = leftNodes.Remove(leafParent); updatedRightNodes = rightNodes; updatedLeftNodes = updatedLeftNodes.Add(leafParent, pakiraTree.Root); } else { rightNodes.ShouldContainKeyAndValue(leafParent, leaf); updatedLeftNodes = leftNodes; updatedRightNodes = rightNodes.Remove(leafParent); updatedRightNodes = updatedRightNodes.Add(leafParent, pakiraTree.Root); } updatedLeftNodes = updatedLeftNodes.AddRange(pakiraTree.leftNodes); updatedRightNodes = updatedRightNodes.AddRange(pakiraTree.rightNodes); updatedParentNodes = parentNodes.Remove(leaf); updatedParentNodes = updatedParentNodes.Add(pakiraTree.Root, leafParent); updatedParentNodes = updatedParentNodes.AddRange(pakiraTree.parentNodes); return(new PakiraTree(Root, updatedLeftNodes, updatedRightNodes, updatedParentNodes)); } }
public bool Contains(KeyValuePair <string, string> pair) { return(_dictionary.Contains(pair)); }
public bool Contains(KeyValuePair <TKey, TValue> pair) { return(_dictionary.Contains(pair)); }
public bool Contains(KeyValuePair <T, V> pair) { return(_items.Contains(pair)); }
public void Contains_Test() { Dictionary<int, string> _dictionary = new Dictionary<int, string> { {1, "aabb"}, {2, "bbcc"}, {3, "ccdd"} }; ImmutableDictionary<int, string> _immutableDictionary = new ImmutableDictionary<int, string>(_dictionary); Assert.IsTrue(_immutableDictionary.Contains(new KeyValuePair<int, string>(1, "aabb"))); Assert.IsFalse(_immutableDictionary.Contains(new KeyValuePair<int, string>(1, "aabbcc"))); }
/// <summary> /// Tests if this dictionary contains a key-value pair. /// </summary> /// <param name="item">The key-value pair to look for.</param> /// <returns> /// <c>true</c> if this dictionary contains <paramref name="item"/>. /// </returns> public bool Contains(KeyValuePair <TKey, TValue> item) { return(innerDictionary.Contains(item)); }
public bool Contains(KeyValuePair <string, object> pair) => _values.Contains(pair);