Пример #1
0
        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")));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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));
 }
Пример #5
0
 public bool Contains(KeyValuePair <TKey, TValue> pair)
 {
     return(_dictionary.Contains(pair));
 }
Пример #6
0
 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")));
 }
Пример #8
0
 /// <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));
 }
Пример #9
0
 public bool Contains(KeyValuePair <string, object> pair) => _values.Contains(pair);