亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? multidictionary.cs

?? C#寫的類似于STL的集合類,首先是C#編寫,可以用于.net變程.
?? CS
?? 第 1 頁 / 共 2 頁
字號:
?//******************************
// Written by Peter Golde
// Copyright (c) 2004-2005, Wintellect
//
// Use and restribution of this code is subject to the license agreement 
// contained in the file "License.txt" accompanying this file.
//******************************

using System;
using System.Collections;
using System.Collections.Generic;

namespace Wintellect.PowerCollections
{
    /// <summary>
    /// <para>The MultiDictionary class that associates values with a key. Unlike an Dictionary,
    /// each key can have multiple values associated with it. When indexing an MultiDictionary, instead
    /// of a single value associated with a key, you retrieve an enumeration of values.</para>
    /// <para>When constructed, you can chose to allow the same value to be associated with a key multiple
    /// times, or only one time. </para>
    /// </summary>
    /// <typeparam name="TKey">The type of the keys.</typeparam>
    /// <typeparam name="TValue">The of values associated with the keys.</typeparam>
    ///<seealso cref="Dictionary&lt;TKey,TValue&gt;"/>
    ///<seealso cref="OrderedMultiDictionary&lt;TKey,TValue&gt;"/>
    [Serializable]
    public class MultiDictionary<TKey, TValue> : MultiDictionaryBase<TKey, TValue>, ICloneable
    {
        // The comparer for comparing keys
        private IEqualityComparer<TKey> keyEqualityComparer;

        // The comparer for comparing values;
        private IEqualityComparer<TValue> valueEqualityComparer;

        // The comparer for compaing keys and values.
        private IEqualityComparer<KeyAndValues> equalityComparer;

        // The hash that holds the keys and values.
        private Hash<KeyAndValues> hash;

        // Whether duplicate values for the same key are allowed.
        private bool allowDuplicateValues;

        /// <summary>
        /// A structure to hold the key and the values associated with the key.
        /// The number of values must always be 1 or greater in a version that is stored, but 
        /// can be zero in a dummy version used only for lookups.
        /// </summary>
        [Serializable]
        private struct KeyAndValues
        {
            /// <summary>
            /// The key.
            /// </summary>
            public TKey Key;

            /// <summary>
            /// The number of values. Always at least 1 except in a dummy version for lookups.
            /// </summary>
            public int Count;

            /// <summary>
            /// An array of values. 
            /// </summary>
            public TValue[] Values;

            /// <summary>
            /// Create a dummy KeyAndValues with just the key, for lookups.
            /// </summary>
            /// <param name="key">The key to use.</param>
            public KeyAndValues(TKey key)
            {
                this.Key = key;
                this.Count = 0;
                this.Values = null;
            }

            /// <summary>
            /// Make a copy of a KeyAndValues, copying the array.
            /// </summary>
            /// <param name="x">KeyAndValues to copy.</param>
            /// <returns>A copied version.</returns>
            public static KeyAndValues Copy(KeyAndValues x)
            {
                KeyAndValues result;

                result.Key = x.Key;
                result.Count = x.Count;

                if (x.Values != null)
                    result.Values = (TValue[])x.Values.Clone();
                else
                    result.Values = null;

                return result;
            }
        }

        /// <summary>
        /// This class implements IEqualityComparer for KeysAndValues, allowing them to be
        /// compared by their keys. An IEqualityComparer on keys is required.
        /// </summary>
        [Serializable]
        private class KeyAndValuesEqualityComparer : IEqualityComparer<KeyAndValues>
        {
            private IEqualityComparer<TKey> keyEqualityComparer;

            public KeyAndValuesEqualityComparer(IEqualityComparer<TKey> keyEqualityComparer)
            {
                this.keyEqualityComparer = keyEqualityComparer;
            }

            public bool Equals(KeyAndValues x, KeyAndValues y)
            {
                return keyEqualityComparer.Equals(x.Key, y.Key);
            }

            public int GetHashCode(KeyAndValues obj)
            {
                return Util.GetHashCode(obj.Key, keyEqualityComparer);
            }
        }


        #region Constructors

        /// <summary>
        /// Create a new MultiDictionary. The default ordering of keys and values are used. If duplicate values
        /// are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
        /// could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
        /// be associated with the same key, although different keys can have the same value. For example, the key "foo" could
        /// have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
        /// </summary>
        /// <remarks>The default ordering of keys and values will be used, as defined by TKey and TValue's implementation
        /// of IComparable&lt;T&gt; (or IComparable if IComparable&lt;T&gt; is not implemented). If a different ordering should be
        /// used, other constructors allow a custom Comparer or IComparer to be passed to changed the ordering.</remarks>
        /// <param name="allowDuplicateValues">Can the same value be associated with a key multiple times?</param>
        /// <exception cref="InvalidOperationException">TKey or TValue does not implement either IComparable&lt;T&gt; or IComparable.</exception>
        public MultiDictionary(bool allowDuplicateValues)
            : this(allowDuplicateValues, EqualityComparer<TKey>.Default, EqualityComparer<TValue>.Default)
        {
        }

        /// <summary>
        /// Create a new MultiDictionary. If duplicate values
        /// are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
        /// could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
        /// be associated with the same key, although different keys can have the same value. For example, the key "foo" could
        /// have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
        /// </summary>
        /// <param name="allowDuplicateValues">Can the same value be associated with a key multiple times?</param>
        /// <param name="keyEqualityComparer">An IEqualityComparer&lt;TKey&gt; instance that will be used to compare keys.</param>
        /// <exception cref="InvalidOperationException">TValue does not implement either IComparable&lt;TValue&gt; or IComparable.</exception>
        public MultiDictionary(bool allowDuplicateValues, IEqualityComparer<TKey> keyEqualityComparer)
            : this(allowDuplicateValues, keyEqualityComparer, EqualityComparer<TValue>.Default)
        {
        }

        /// <summary>
        /// Create a new MultiDictionary. If duplicate values
        /// are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
        /// could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
        /// be associated with the same key, although different keys can have the same value. For example, the key "foo" could
        /// have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
        /// </summary>
        /// <param name="allowDuplicateValues">Can the same value be associated with a key multiple times?</param>
        /// <param name="keyEqualityComparer">An IEqualityComparer&lt;TKey&gt; instance that will be used to compare keys.</param>
        /// <param name="valueEqualityComparer">An IEqualityComparer&lt;TValue&gt; instance that will be used to compare values.</param>
        public MultiDictionary(bool allowDuplicateValues, IEqualityComparer<TKey> keyEqualityComparer, IEqualityComparer<TValue> valueEqualityComparer)
        {
            if (keyEqualityComparer == null)
                throw new ArgumentNullException("keyEqualityComparer");
            if (valueEqualityComparer == null)
                throw new ArgumentNullException("valueEqualityComparer");

            this.allowDuplicateValues = allowDuplicateValues;
            this.keyEqualityComparer = keyEqualityComparer;
            this.valueEqualityComparer = valueEqualityComparer;
            this.equalityComparer = new KeyAndValuesEqualityComparer(keyEqualityComparer);
            this.hash = new Hash<KeyAndValues>(equalityComparer);
        }

        /// <summary>
        /// Create a new MultiDictionary. Private constructor, for use by Clone().
        /// </summary>
        private MultiDictionary(bool allowDuplicateValues, IEqualityComparer<TKey> keyEqualityComparer, IEqualityComparer<TValue> valueEqualityComparer, IEqualityComparer<KeyAndValues> equalityComparer, Hash<KeyAndValues> hash)
        {
            if (keyEqualityComparer == null)
                throw new ArgumentNullException("keyEqualityComparer");
            if (valueEqualityComparer == null)
                throw new ArgumentNullException("valueEqualityComparer");

            this.allowDuplicateValues = allowDuplicateValues;
            this.keyEqualityComparer = keyEqualityComparer;
            this.valueEqualityComparer = valueEqualityComparer;
            this.equalityComparer = equalityComparer;
            this.hash = hash;
        }


        #endregion Constructors

        #region Add or remove items

        /// <summary>
        /// <para>Adds a new value to be associated with a key. If duplicate values are permitted, this
        /// method always adds a new key-value pair to the dictionary.</para>
        /// <para>If duplicate values are not permitted, and <paramref name="key"/> already has a value
        /// equal to <paramref name="value"/> associated with it, then that value is replaced with <paramref name="value"/>,
        /// and the number of values associate with <paramref name="key"/> is unchanged.</para>
        /// </summary>
        /// <param name="key">The key to associate with.</param>
        /// <param name="value">The value to associated with <paramref name="key"/>.</param>
        public sealed override void Add(TKey key, TValue value)
        {
            KeyAndValues keyValues = new KeyAndValues(key);
            KeyAndValues existing;

            if (hash.Find(keyValues, false, out existing)) {
                // There already is an item in the hash table equal to this key. Add the new value,
                // taking into account duplicates if needed.
                int existingCount = existing.Count;
                if (!allowDuplicateValues) {
                    int valueHash = Util.GetHashCode(value, valueEqualityComparer);
                    for (int i = 0; i < existingCount; ++i) {
                        if (Util.GetHashCode(existing.Values[i], valueEqualityComparer) == valueHash &&
                            valueEqualityComparer.Equals(existing.Values[i], value)) {
                            // Found an equal existing value. Replace it and we're done.
                            existing.Values[i] = value;
                            return;
                        }
                    }
                }

                // Add a new value to an existing key.
                if (existingCount == existing.Values.Length) {
                    // Grow the array to make room.
                    TValue[] newValues = new TValue[existingCount * 2];
                    Array.Copy(existing.Values, newValues, existingCount);
                    existing.Values = newValues;
                }
                existing.Values[existingCount] = value;
                existing.Count = existingCount + 1;

                // Update the hash table.
                hash.Find(existing, true, out keyValues);
                return;
            }
            else {
                // No item with this key. Add it.
                keyValues.Count = 1;
                keyValues.Values = new TValue[1] { value };
                hash.Insert(keyValues, true, out existing);
                return;
            }
        }

        /// <summary>
        /// Removes a given value from the values associated with a key. If the
        /// last value is removed from a key, the key is removed also.
        /// </summary>
        /// <param name="key">A key to remove a value from.</param>
        /// <param name="value">The value to remove.</param>
        /// <returns>True if <paramref name="value"/> was associated with <paramref name="key"/> (and was
        /// therefore removed). False if <paramref name="value"/> was not associated with <paramref name="key"/>.</returns>
        public sealed override bool Remove(TKey key, TValue value)
        {
            KeyAndValues keyValues = new KeyAndValues(key);
            KeyAndValues existing;

            if (hash.Find(keyValues, false, out existing)) {
                // There is an item in the hash table equal to this key. Find the value.
                int existingCount = existing.Count;
                int valueHash = Util.GetHashCode(value, valueEqualityComparer);
                int indexFound = -1;
                for (int i = 0; i < existingCount; ++i) {
                    if (Util.GetHashCode(existing.Values[i], valueEqualityComparer) == valueHash &&
                        valueEqualityComparer.Equals(existing.Values[i], value)) 
                    {
                        // Found an equal existing value
                        indexFound = i;
                    }
                }

                if (existingCount == 1) {
                    // Removing the last value. Remove the key.
                    hash.Delete(existing, out keyValues);
                    return true;
                }
                else if (indexFound >= 0) {
                    // Found a value. Remove it.
                    if (indexFound < existingCount - 1)
                        Array.Copy(existing.Values, indexFound + 1, existing.Values, indexFound, existingCount - indexFound - 1);
                    existing.Count = existingCount - 1;

                    // Update the hash.
                    hash.Find(existing, true, out keyValues);
                    return true;
                }
                else {

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线不卡视频| 欧美视频一区二区三区| 色88888久久久久久影院野外| 色天天综合色天天久久| 正在播放一区二区| 精品88久久久久88久久久| 亚洲国产精品黑人久久久| 亚洲欧美日韩国产成人精品影院| 亚洲午夜国产一区99re久久| 久久se精品一区二区| jlzzjlzz国产精品久久| 制服丝袜在线91| 国产视频一区二区三区在线观看| 一区二区三区四区乱视频| 麻豆国产精品一区二区三区| 成人涩涩免费视频| 在线播放视频一区| 久久精品一二三| 偷拍日韩校园综合在线| 国产成人av电影免费在线观看| 在线一区二区视频| 久久综合给合久久狠狠狠97色69| 亚洲人妖av一区二区| 蜜桃视频第一区免费观看| 91欧美一区二区| 欧美一区二区三区在线观看| 国产精品久久久久久福利一牛影视| 亚洲福利电影网| 成人动漫一区二区| 日韩精品最新网址| 一区二区三区日本| 国产成人自拍网| 在线成人av网站| 亚洲精品中文字幕乱码三区| 韩国欧美国产1区| 欧美亚洲综合在线| 中文字幕一区在线| 欧美一区二区视频观看视频| 国产精品成人午夜| 国内精品写真在线观看| 欧美精品丝袜久久久中文字幕| 中文字幕永久在线不卡| 国产精品资源站在线| 欧美一区二区在线不卡| 一区二区三区欧美| av不卡在线播放| 久久综合色播五月| 日本成人超碰在线观看| 在线看国产一区| 一区在线观看免费| 福利91精品一区二区三区| 亚洲精品一区二区三区福利| 日韩vs国产vs欧美| 精品视频在线免费| 亚洲桃色在线一区| 处破女av一区二区| 欧美激情资源网| 国产在线播放一区二区三区| 欧美一区二区视频在线观看2022| 亚洲va中文字幕| 欧美在线视频日韩| 一区二区三区在线免费视频| 91麻豆自制传媒国产之光| 久久九九99视频| 激情综合亚洲精品| 日韩久久久久久| 久久99日本精品| 日韩美女一区二区三区| 免费av成人在线| 欧美一级生活片| 蜜臀久久久99精品久久久久久| 这里只有精品视频在线观看| 日韩国产在线观看| 91精品婷婷国产综合久久性色| 亚洲成人av免费| 在线观看91av| 蜜臀av亚洲一区中文字幕| 日韩无一区二区| 日本va欧美va欧美va精品| 日韩免费视频一区| 精品中文字幕一区二区小辣椒 | 国产精品久久精品日日| 国产不卡视频在线观看| 国产精品毛片大码女人| 成人黄色777网| 亚洲欧美激情插 | 亚洲成av人影院在线观看网| 欧美三电影在线| 香蕉av福利精品导航| 7799精品视频| 久久不见久久见免费视频7| 久久影院电视剧免费观看| 高清不卡在线观看av| 亚洲欧洲制服丝袜| 欧美夫妻性生活| 麻豆成人综合网| 欧美激情一区二区三区四区| www.久久久久久久久| 夜夜操天天操亚洲| 欧美电影影音先锋| 国产乱码精品一区二区三区五月婷 | 久久综合色综合88| aaa欧美日韩| 亚洲一区二区三区四区在线免费观看| 亚洲制服丝袜一区| 欧美一区二区在线视频| 国产精品一区二区三区乱码| 一色桃子久久精品亚洲| 欧美四级电影网| 久久爱www久久做| 中文字幕一区二区三区乱码在线| 欧美亚洲免费在线一区| 日韩中文字幕1| 国产女人aaa级久久久级 | 亚洲午夜视频在线观看| 精品毛片乱码1区2区3区| 国产高清精品久久久久| 亚洲综合一区二区三区| 欧美成人性战久久| 一本一道久久a久久精品 | 精品欧美一区二区在线观看| www.成人在线| 免费观看久久久4p| 中文字幕在线不卡一区| 欧美伦理视频网站| 国产91富婆露脸刺激对白| 一二三区精品福利视频| 2020国产精品| 欧美无人高清视频在线观看| 国产呦精品一区二区三区网站| 亚洲精品乱码久久久久| 精品99一区二区| 在线看不卡av| 国产精品综合久久| 午夜a成v人精品| 国产精品福利影院| 精品精品国产高清a毛片牛牛| 91小宝寻花一区二区三区| 毛片av一区二区三区| 一区二区三区鲁丝不卡| 久久久一区二区三区| 欧美专区日韩专区| 不卡的av电影| 精品一区二区三区不卡| 亚洲大片在线观看| 中文字幕一区二区在线观看| 欧美哺乳videos| 欧美亚洲一区二区在线观看| 国产suv一区二区三区88区| 男女性色大片免费观看一区二区 | 91成人免费在线| 不卡的电视剧免费网站有什么| 久久精品国产久精国产| 亚洲国产sm捆绑调教视频 | 99视频有精品| 国产乱码精品一区二区三区忘忧草| 亚洲va欧美va人人爽| 亚洲欧美另类小说视频| 国产女主播视频一区二区| 精品嫩草影院久久| 91在线精品一区二区| 天堂av在线一区| 欧美精品 国产精品| 亚洲一区中文日韩| 欧洲精品一区二区| 成人av资源站| 日韩精品福利网| 一二三区精品视频| 亚洲男人的天堂在线观看| 国产精品系列在线| 久久久久高清精品| 精品国产电影一区二区| 亚洲gay无套男同| 亚洲午夜国产一区99re久久| 亚洲精品视频免费看| **性色生活片久久毛片| 国产女主播在线一区二区| 久久婷婷国产综合精品青草| 精品国产91九色蝌蚪| 精品精品国产高清a毛片牛牛| 日韩一卡二卡三卡四卡| 这里只有精品99re| 欧美一区二区三区视频免费播放| 欧美日韩日本视频| 欧美嫩在线观看| 欧美精品一二三| 欧美一卡二卡在线| 日韩一区二区精品| 精品av综合导航| 国产日本亚洲高清| 日本一区二区不卡视频| 国产精品视频麻豆| 亚洲特黄一级片| 亚洲综合清纯丝袜自拍| 香蕉av福利精品导航| 免费观看日韩av| 国产精品91xxx| 成人网男人的天堂| 色欧美片视频在线观看| 欧美无乱码久久久免费午夜一区|