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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ordereddictionary.cs

?? C#寫的類似于STL的集合類,首先是C#編寫,可以用于.net變程.
?? CS
?? 第 1 頁 / 共 3 頁
字號:
//******************************
// 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>
	/// OrderedDictionary&lt;TKey, TValue&gt; is a collection that maps keys of type TKey
	/// to values of type TValue. The keys are maintained in a sorted order, and at most one value
	/// is permitted for each key.
	/// </summary>
	/// <remarks>
	/// <p>The keys are compared in one of three ways. If TKey implements IComparable&lt;TKey&gt; or IComparable,
	/// then the CompareTo method of that interface will be used to compare elements. Alternatively, a comparison
	/// function can be passed in either as a delegate, or as an instance of IComparer&lt;TKey&gt;.</p>
	/// <p>OrderedDictionary is implemented as a balanced binary tree. Inserting, deleting, and looking up an
	/// an element all are done in log(N) type, where N is the number of keys in the tree.</p>
	/// <p><see cref="Dictionary&lt;TKey,TValue&gt;"/> is similar, but uses hashing instead of comparison, and does not maintain
	/// the keys in sorted order.</p>
	///</remarks>
	///<seealso cref="Dictionary&lt;TKey,TValue&gt;"/>
    [Serializable]
	public class OrderedDictionary<TKey,TValue>: DictionaryBase<TKey,TValue>, ICloneable
	{
        // The comparer for comparing keys. This is saved to return from the Comparer property,
        // but is otherwise not used.
        private IComparer<TKey> keyComparer;

		// The comparer for comparing key-value pairs.
		private IComparer<KeyValuePair<TKey,TValue>> pairComparer;

		private RedBlackTree<KeyValuePair<TKey,TValue>> tree;

        /// <summary>
        /// Helper function to create a new KeyValuePair struct.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <returns>A new KeyValuePair.</returns>
        private static KeyValuePair<TKey,TValue> NewPair(TKey key, TValue value) {
            KeyValuePair<TKey, TValue> pair = new KeyValuePair<TKey,TValue>(key,value);
            return pair;
        }

        /// <summary>
        /// Helper function to create a new KeyValuePair struct with a default value.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>A new KeyValuePair.</returns>
        private static KeyValuePair<TKey, TValue> NewPair(TKey key)
        {
            KeyValuePair<TKey, TValue> pair = new KeyValuePair<TKey,TValue>(key, default(TValue));
            return pair;
        }

        /// <summary>
        /// Creates a new OrderedDictionary. The TKey must implemented IComparable&lt;TKey&gt;
		/// or IComparable. 
		/// The CompareTo method of this interface will be used to compare keys in this dictionary.
		/// </summary>
		/// <exception cref="InvalidOperationException">TKey does not implement IComparable&lt;TKey&gt;.</exception>
		public OrderedDictionary() :
            this(Comparers.DefaultComparer<TKey>())
		{
		}

        /// <summary>
        /// Creates a new OrderedDictionary. The Compare method of the passed comparison object
		/// will be used to compare keys in this dictionary.
		/// </summary>
		/// <remarks>
		/// The GetHashCode and Equals methods of the provided IComparer&lt;TKey&gt; will never
		/// be called, and need not be implemented.</remarks>
		/// <param name="comparer">An instance of IComparer&lt;TKey&gt; that will be used to compare keys.</param>
		public OrderedDictionary(IComparer<TKey> comparer) :
            this(null, comparer, Comparers.ComparerKeyValueFromComparerKey<TKey, TValue>(comparer))
		{
            if (comparer == null)
                throw new ArgumentNullException("comparer");
        }

        /// <summary>
		/// Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary.
		/// </summary>
		/// <param name="comparison">A delegate to a method that will be used to compare keys.</param>
		public OrderedDictionary(Comparison<TKey> comparison) :
            this(null, Comparers.ComparerFromComparison<TKey>(comparison), Comparers.ComparerKeyValueFromComparisonKey<TKey, TValue>(comparison))
		{
        }

        /// <summary>
        /// <para>Creates a new OrderedDictionary. The TKey must implemented IComparable&lt;TKey&gt;
        /// or IComparable. 
        /// The CompareTo method of this interface will be used to compare keys in this dictionary.</para>
        /// <para>A collection and keys and values (typically another dictionary) is used to initialized the 
        /// contents of the dictionary.</para>
        /// </summary>
        /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
        /// <exception cref="InvalidOperationException">TKey does not implement IComparable&lt;TKey&gt;.</exception>
        public OrderedDictionary(IEnumerable<KeyValuePair<TKey,TValue>> keysAndValues)
            : this(keysAndValues, Comparers.DefaultComparer<TKey>())
        {
        }

        /// <summary>
        /// <para>Creates a new OrderedDictionary. The Compare method of the passed comparison object
        /// will be used to compare keys in this dictionary.</para>
        /// <para>A collection and keys and values (typically another dictionary) is used to initialized the 
        /// contents of the dictionary.</para>
        /// </summary>
        /// <remarks>
        /// The GetHashCode and Equals methods of the provided IComparer&lt;TKey&gt; will never
        /// be called, and need not be implemented.</remarks>
        /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
        /// <param name="comparer">An instance of IComparer&lt;TKey&gt; that will be used to compare keys.</param>
        public OrderedDictionary(IEnumerable<KeyValuePair<TKey, TValue>> keysAndValues, IComparer<TKey> comparer)
            : this(keysAndValues, comparer, Comparers.ComparerKeyValueFromComparerKey<TKey, TValue>(comparer))
        {
            if (comparer == null)
                throw new ArgumentNullException("comparer");
        }

        /// <summary>
        /// <para>Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary.</para>
        /// <para>A collection and keys and values (typically another dictionary) is used to initialized the 
        /// contents of the dictionary.</para>
        /// </summary>
        /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
        /// <param name="comparison">A delegate to a method that will be used to compare keys.</param>
        public OrderedDictionary(IEnumerable<KeyValuePair<TKey, TValue>> keysAndValues, Comparison<TKey> comparison)
            : this(keysAndValues, Comparers.ComparerFromComparison<TKey>(comparison), Comparers.ComparerKeyValueFromComparisonKey<TKey, TValue>(comparison))
        {
        }

        /// <summary>
		/// Creates a new OrderedDictionary. The passed comparer 
		/// will be used to compare key-value pairs in this dictionary. Used internally  
		/// from other constructors.
		/// </summary>
        /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
        /// <param name="keyComparer">An IComparer that will be used to compare keys.</param>
        /// <param name="pairComparer">An IComparer that will be used to compare key-value pairs.</param>
        private OrderedDictionary(IEnumerable<KeyValuePair<TKey,TValue>> keysAndValues, IComparer<TKey> keyComparer, IComparer<KeyValuePair<TKey,TValue>> pairComparer)
		{
            this.keyComparer = keyComparer;
            this.pairComparer = pairComparer;
            tree = new RedBlackTree<KeyValuePair<TKey,TValue>>(this.pairComparer);

            if (keysAndValues != null)
                AddMany(keysAndValues);
		}

        /// <summary>
        /// Creates a new OrderedDictionary. The passed comparison delegate 
        /// will be used to compare keys in this dictionary, and the given tree is used. Used internally for Clone().
        /// </summary>
        /// <param name="keyComparer">An IComparer that will be used to compare keys.</param>
        /// <param name="pairComparer">A delegate to a method that will be used to compare key-value pairs.</param>
        /// <param name="tree">RedBlackTree that contains the data for the dictionary.</param>
        private OrderedDictionary(IComparer<TKey> keyComparer, IComparer<KeyValuePair<TKey, TValue>> pairComparer, RedBlackTree<KeyValuePair<TKey, TValue>> tree)
        {
            this.keyComparer = keyComparer;
            this.pairComparer = pairComparer;
            this.tree = tree;
        }

        /// <summary>
        /// Makes a shallow clone of this dictionary; i.e., if keys or values of the
		/// dictionary are reference types, then they are not cloned. If TKey or TValue is a value type,
		/// then each element is copied as if by simple assignment.
		/// </summary>
        /// <remarks>Cloning the dictionary takes time O(N), where N is the number of keys in the dictionary.</remarks>
        /// <returns>The cloned dictionary.</returns>
        public OrderedDictionary<TKey,TValue> Clone()
		{
			OrderedDictionary<TKey,TValue> newDict = new OrderedDictionary<TKey,TValue>(keyComparer, pairComparer, tree.Clone());
			return newDict;
		}

        /// <summary>
        /// Throw an InvalidOperationException indicating that this type is not cloneable.
        /// </summary>
        /// <param name="t">Type to test.</param>
        private void NonCloneableType(Type t)
        {
            throw new InvalidOperationException(string.Format(Strings.TypeNotCloneable, t.FullName));
        }

        /// <summary>
		/// Makes a deep clone of this dictionary. A new dictionary is created with a clone of
		/// each entry of this dictionary, by calling ICloneable.Clone on each element. If TKey or TValue is
		/// a value type, then each element is copied as if by simple assignment.
		/// </summary>
		/// <remarks><para>If TKey or TValue is a reference type, it must implement
        /// ICloneable. Otherwise, an InvalidOperationException is thrown.</para>
        /// <para>Cloning the dictionary takes time O(N log N), where N is the number of keys in the dictionary.</para></remarks>
        /// <returns>The cloned dictionary.</returns>
        /// <exception cref="InvalidOperationException">TKey or TValue is a reference type that does not implement ICloneable.</exception>
		public OrderedDictionary<TKey,TValue> CloneContents()
		{
            bool keyIsValueType, valueIsValueType;

            // Make sure that TKey and TValue can be cloned.
            if (!Util.IsCloneableType(typeof(TKey), out keyIsValueType))
                NonCloneableType(typeof(TKey));

            if (!Util.IsCloneableType(typeof(TValue), out valueIsValueType))
                NonCloneableType(typeof(TValue));

            OrderedDictionary<TKey, TValue> newDict = new OrderedDictionary<TKey, TValue>(null, keyComparer, pairComparer);

            foreach (KeyValuePair<TKey, TValue> pair in tree) {
                // Clone the key and value parts of the pair. Value types can be cloned
                // by just copying them, otherwise, ICloneable is used.
                TKey keyClone;
                TValue valueClone;

                if (keyIsValueType)
                    keyClone = pair.Key;
                else {
                    if (pair.Key == null)
                        keyClone = default(TKey);  // Really null, because we know TKey isn't a value type.
                    else
                        keyClone = (TKey)(((ICloneable)pair.Key).Clone());
                }

                if (valueIsValueType)
                    valueClone = pair.Value;
                else {
                    if (pair.Value == null)
                        valueClone = default(TValue);   // Really null, because we know TKey isn't a value type.
                    else
                        valueClone = (TValue)(((ICloneable)pair.Value).Clone());
                }

                newDict.Add(keyClone, valueClone);
            }

            return newDict;
        }
   
        /// <summary>
        /// Returns the IComparer&lt;T&gt; used to compare keys in this dictionary. 
        /// </summary>
        /// <value>If the dictionary was created using a comparer, that comparer is returned. If the dictionary was
        /// created using a comparison delegate, then a comparer equivalent to that delegate
        /// is returned. Otherwise
        /// the default comparer for TKey (Comparer&lt;TKey&gt;.Default) is returned.</value>
        public IComparer<TKey> Comparer
        {
            get
            {
                return this.keyComparer;
            }
        }


        /// <summary>
        /// Returns a View collection that can be used for enumerating the keys and values in the collection in 
        /// reversed order.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久久久黄色| 国产精品69毛片高清亚洲| 91免费观看国产| 亚洲天堂免费看| 91免费精品国自产拍在线不卡| 中文字幕在线一区免费| 国产91在线观看| 亚洲视频香蕉人妖| 在线视频你懂得一区| 亚洲国产综合91精品麻豆| 欧美色成人综合| 蜜臀av一区二区| 国产欧美日韩在线视频| www.亚洲人| 性欧美疯狂xxxxbbbb| 在线综合+亚洲+欧美中文字幕| 久久精品国产精品亚洲精品| 久久精品免费在线观看| 99视频在线观看一区三区| 亚洲精品国久久99热| 欧美日韩精品二区第二页| 麻豆精品久久久| 亚洲视频一区在线观看| 欧美日韩国产综合一区二区三区| 美脚の诱脚舐め脚责91| 中文天堂在线一区| 欧美日韩国产一级片| 国产精品一卡二| 亚洲福中文字幕伊人影院| 日韩欧美亚洲一区二区| 99久久免费精品高清特色大片| 午夜视频一区二区| 久久亚洲精华国产精华液| 色哟哟在线观看一区二区三区| 日韩精品五月天| 欧美激情一区二区三区全黄| 欧美视频在线不卡| 国产精品一区二区久久不卡| 亚洲一区二区三区小说| 精品99一区二区三区| 色88888久久久久久影院按摩| 蜜桃精品视频在线| 中文字幕一区二| 精品久久久久久亚洲综合网| 日本乱人伦一区| 国产精品888| 日本在线观看不卡视频| 1000部国产精品成人观看| 日韩女优制服丝袜电影| 欧美性三三影院| 成人av高清在线| 国产一区二区三区不卡在线观看| 日韩成人免费看| 亚洲日本丝袜连裤袜办公室| 国产婷婷色一区二区三区| 欧美高清你懂得| 在线精品视频免费播放| 成人av资源在线观看| 国产综合色在线视频区| 五月婷婷另类国产| 亚洲精品视频在线| 国产精品乱码一区二区三区软件| 精品国产免费人成在线观看| 7777女厕盗摄久久久| 欧美三级电影在线看| av在线一区二区三区| 国产成人av自拍| 国产精品资源网| 麻豆国产欧美日韩综合精品二区| 午夜激情综合网| 亚洲超碰精品一区二区| 亚洲男人天堂一区| 国产精品毛片高清在线完整版 | 亚洲一区二区三区四区的| 中文字幕不卡的av| 久久久久久久久久久99999| 精品国产一二三| 久久久不卡网国产精品二区| 日韩欧美成人一区| 欧美一区二区三区在线视频| 欧美一二三四区在线| 欧美一级黄色录像| 欧美一区二区三区日韩| 8x福利精品第一导航| 欧美一区二区三区视频免费| 91精品国产91久久久久久一区二区| 91精品国产免费久久综合| 欧美一级片免费看| 精品国产污污免费网站入口| 久久久久国产精品免费免费搜索| 国产三区在线成人av| 国产免费观看久久| 国产精品女主播av| 亚洲欧美激情插| 亚洲第一主播视频| 五月激情六月综合| 蜜桃一区二区三区在线| 激情伊人五月天久久综合| 国产美女精品一区二区三区| 成人午夜视频免费看| 91麻豆精东视频| 欧美日本韩国一区二区三区视频 | 蜜臀91精品一区二区三区| 美日韩一区二区三区| 狠狠v欧美v日韩v亚洲ⅴ| 国产91精品在线观看| 99热精品一区二区| 欧美怡红院视频| 欧美tickling挠脚心丨vk| 国产亚洲欧美一区在线观看| 亚洲男人电影天堂| 青青草成人在线观看| 国产精品夜夜嗨| 一本色道亚洲精品aⅴ| 欧美日韩精品免费| 久久久精品欧美丰满| 亚洲综合在线五月| 麻豆久久久久久久| 成人av在线资源网站| 欧美性色黄大片| 久久久久国产成人精品亚洲午夜 | 91麻豆精品国产91久久久久久| 精品美女一区二区| 中文字幕在线播放不卡一区| 日韩精品久久理论片| 国产91在线|亚洲| 8x8x8国产精品| 日韩一区在线看| 极品美女销魂一区二区三区 | 中文字幕欧美激情一区| 一区二区三区免费网站| 精品一区二区在线看| 91社区在线播放| 久久夜色精品国产噜噜av| 亚洲精品免费在线观看| 久久99这里只有精品| 色爱区综合激月婷婷| 国产欧美一区二区三区在线看蜜臀| 亚洲在线视频网站| 国产成人免费av在线| 日韩欧美久久久| 亚洲一区二区三区中文字幕在线 | 久久99精品一区二区三区三区| 日本韩国视频一区二区| 久久这里只有精品首页| 亚洲va天堂va国产va久| av一区二区三区| 国产日韩欧美激情| 五月天亚洲婷婷| 色女孩综合影院| 国产精品久久久久久久午夜片 | 国产成人精品综合在线观看| 欧美大片国产精品| 一区二区三区在线观看动漫 | 国产一区亚洲一区| 欧美日韩国产美| 一区二区三区国产精品| 成人午夜视频网站| 久久久久久夜精品精品免费| 另类人妖一区二区av| 欧美日韩国产a| 亚洲国产欧美另类丝袜| 色又黄又爽网站www久久| 亚洲天堂免费看| 色综合咪咪久久| 亚洲男人天堂av| 色婷婷综合久久久中文字幕| 一区在线中文字幕| 成人午夜视频网站| 国产精品每日更新| 99免费精品在线| 国产精品久久久久久久久免费丝袜| 福利视频网站一区二区三区| 久久久激情视频| 成人美女视频在线观看18| 国产欧美精品一区二区色综合 | 91久久精品一区二区三| 1024精品合集| 欧美性猛片xxxx免费看久爱| 亚洲二区在线视频| 欧美色视频在线| 美女性感视频久久| 精品三级在线观看| 国产剧情一区在线| 中文乱码免费一区二区| 99国产精品国产精品毛片| 伊人一区二区三区| 欧美日韩国产乱码电影| 奇米一区二区三区| 久久伊人中文字幕| 成人晚上爱看视频| 亚洲摸摸操操av| 欧美丰满美乳xxx高潮www| 麻豆91精品视频| 欧美高清在线一区二区| 99re热这里只有精品视频| 亚洲一区二区综合| 欧美www视频| av成人老司机| 全国精品久久少妇|