Esempio n. 1
0
        public void Remove(TKey key1, TKey key2)
        {
            var oneKey = new MultiKey <TKey>(key1, key2);
            var twoKey = new MultiKey <TKey>(key2, key1);

            base.Remove(oneKey);
            base.Remove(twoKey);
            ArrayData.Remove(key1);
            ArrayData.Remove(key2);
        }
Esempio n. 2
0
        public new void Remove(MultiKey <TKey> key)
        {
            var oneKey = new MultiKey <TKey>(key.Item1, key.Item2);
            var twoKey = new MultiKey <TKey>(key.Item2, key.Item1);

            base.Remove(oneKey);
            base.Remove(twoKey);
            ArrayData.Remove(key.Item1);
            ArrayData.Remove(key.Item2);
        }
Esempio n. 3
0
        public bool ContainsKey(TKey key1, TKey key2)
        {
            var oneKey = new MultiKey <TKey>(key1, key2);
            var twoKey = new MultiKey <TKey>(key2, key1);

            if (ContainsKey(oneKey) || ContainsKey(twoKey))
            {
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public TValue Get(TKey key1, TKey key2)
        {
            var oneKey = new MultiKey <TKey>(key1, key2);
            var twoKey = new MultiKey <TKey>(key2, key1);

            if (ContainsKey(oneKey))
            {
                return(this[oneKey]);
            }
            else if (ContainsKey(twoKey))
            {
                return(this[twoKey]);
            }
            return(default);
Esempio n. 5
0
        // 如果没有,则会自动添加一个
        public void Change(TKey key1, TKey key2, TValue value)
        {
            var oneKey = new MultiKey <TKey>(key1, key2);
            var twoKey = new MultiKey <TKey>(key2, key1);

            if (ContainsKey(oneKey))
            {
                this[oneKey] = value;
            }
            else
            {
                this[twoKey] = value;
            }
            if (!ArrayData.ContainsKey(key1))
            {
                ArrayData[key1] = new Dictionary <TKey, TValue>();
            }
            if (!ArrayData.ContainsKey(key2))
            {
                ArrayData[key2] = new Dictionary <TKey, TValue>();
            }
            ArrayData[key1][key2] = value;
            ArrayData[key2][key1] = value;
        }