亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲国产成人午夜在线一区| 午夜视频在线观看一区二区| 亚洲综合在线电影| 老司机免费视频一区二区三区| 丁香另类激情小说| 日韩一区国产二区欧美三区| 亚洲欧美另类小说视频| 久久er99热精品一区二区| 在线影视一区二区三区| 久久精品一区蜜桃臀影院| 天天做天天摸天天爽国产一区| 不卡在线观看av| 国产亚洲欧美色| 日韩电影免费在线看| av一区二区三区四区| 久久久99久久精品欧美| 蜜桃视频一区二区| 7777精品伊人久久久大香线蕉超级流畅| 国产精品私人自拍| 国产一区在线精品| 日韩欧美不卡一区| 青青草原综合久久大伊人精品| 91久久精品午夜一区二区| 国产精品区一区二区三| 国产成人免费视频精品含羞草妖精 | 蜜臀国产一区二区三区在线播放| 一本一道波多野结衣一区二区 | 国产精品一区二区x88av| 91精品国产综合久久精品麻豆| 一个色综合av| 在线免费不卡视频| 亚洲午夜久久久久久久久电影院 | 国产成人综合在线观看| 欧美xxxx在线观看| 激情深爱一区二区| 亚洲精品一区二区三区福利 | 免费av成人在线| 欧美一级高清片| 美国三级日本三级久久99| 欧美一区二区三区视频在线观看| 男男成人高潮片免费网站| 日韩欧美电影一二三| 黄页视频在线91| 中文字幕欧美日韩一区| 91亚洲午夜精品久久久久久| 一区二区三区不卡在线观看 | 国产真实乱子伦精品视频| 久久久三级国产网站| 国产剧情一区在线| 欧美国产1区2区| 91高清视频免费看| 日本午夜一区二区| 国产欧美日韩激情| 一本色道久久综合精品竹菊| 亚洲妇熟xx妇色黄| 精品福利一区二区三区免费视频| 粉嫩av一区二区三区粉嫩| 又紧又大又爽精品一区二区| 69p69国产精品| 丁香婷婷深情五月亚洲| 一区二区三区日韩| 91精品免费观看| 国产成人亚洲综合a∨婷婷| 中文字幕在线免费不卡| 欧美日韩在线播放三区| 美日韩一区二区三区| 国产精品视频你懂的| 欧美天堂亚洲电影院在线播放| 久久精品国产精品亚洲红杏| 中文字幕一区在线观看| 欧美丰满一区二区免费视频 | 国产一区欧美日韩| 成人免费在线视频观看| 在线综合+亚洲+欧美中文字幕| 国产一区二区精品久久99| 亚洲色图视频网站| 久久婷婷综合激情| 欧美在线观看一区二区| 国产一区二区调教| 亚洲一级二级三级在线免费观看| 亚洲精品在线观看视频| 欧美日韩精品免费| av成人免费在线| 激情欧美一区二区三区在线观看| 亚洲第一综合色| 亚洲欧美中日韩| 精品动漫一区二区三区在线观看| 在线精品观看国产| 成人av电影免费在线播放| 青青草国产精品97视觉盛宴| 一区二区三区在线视频观看| 国产精品欧美精品| 日韩三级免费观看| 欧美亚洲一区三区| av成人动漫在线观看| 国产精品主播直播| 免费人成精品欧美精品| 亚洲精品成人精品456| 日本一区二区免费在线| 精品久久99ma| 91精品国产综合久久婷婷香蕉| 色狠狠色狠狠综合| 99视频精品全部免费在线| 国产乱码精品一区二区三区忘忧草| 午夜精品久久久久久久久| 亚洲欧美国产三级| 亚洲免费av高清| 亚洲色图欧美偷拍| 成人免费一区二区三区视频| 中文字幕在线视频一区| 国产视频一区二区三区在线观看 | 一区二区三区在线观看视频| 国产精品天干天干在线综合| 欧美激情艳妇裸体舞| 国产亚洲精品aa午夜观看| 国产午夜精品久久| 久久精品亚洲精品国产欧美| 久久精品视频一区| 国产亚洲综合性久久久影院| 中文一区二区在线观看| 国产精品国产自产拍在线| 国产精品国产精品国产专区不蜜| 国产精品乱码人人做人人爱| 国产精品久久久久久妇女6080| 国产精品天天摸av网| 亚洲色图在线看| 亚洲美女少妇撒尿| 亚洲成人黄色影院| 日韩成人免费电影| 极品销魂美女一区二区三区| 国产精品一区二区无线| 成人a免费在线看| 日本韩国一区二区| 欧美美女bb生活片| 日韩欧美国产不卡| 国产精品网站导航| 午夜精彩视频在线观看不卡| 久久国产夜色精品鲁鲁99| 激情五月婷婷综合网| gogo大胆日本视频一区| 欧美日韩在线播放一区| 久久综合五月天婷婷伊人| 国产精品免费人成网站| 亚洲五码中文字幕| 精品一区二区国语对白| jlzzjlzz亚洲日本少妇| 欧美精品高清视频| 日本一区二区三区免费乱视频| 亚洲欧美一区二区三区国产精品 | 亚洲精品国久久99热| 日韩精品欧美成人高清一区二区| 精品在线观看免费| 99精品在线免费| 欧美一区二区成人6969| 国产精品电影院| 奇米色777欧美一区二区| 成人性生交大片免费看在线播放 | 在线观看av一区| 久久综合久久综合久久| 亚洲自拍与偷拍| 黑人精品欧美一区二区蜜桃| 色婷婷一区二区三区四区| 日韩一本二本av| 一区二区三区四区激情| 国产成人午夜电影网| 欧美日韩国产高清一区二区| 中文字幕国产一区| 久久99国产精品免费网站| 欧美性猛片aaaaaaa做受| 蜜桃久久久久久久| 欧美激情一区二区三区不卡| 久久久久综合网| 亚洲线精品一区二区三区八戒| 欧美综合亚洲图片综合区| 蜜桃精品在线观看| 视频一区欧美精品| 色综合中文综合网| 欧美激情在线观看视频免费| 日韩国产一二三区| 一本大道av伊人久久综合| 久久欧美中文字幕| 盗摄精品av一区二区三区| 盗摄精品av一区二区三区| 在线欧美一区二区| 综合久久久久综合| 成人综合婷婷国产精品久久 | 麻豆一区二区三| 欧美日韩亚洲国产综合| 亚洲精品乱码久久久久久久久| 国产91精品入口| www欧美成人18+| 久久精品国产第一区二区三区| 91精品国产品国语在线不卡 | 亚洲主播在线播放| 色综合久久88色综合天天免费| 国产精品色婷婷久久58| 丰满白嫩尤物一区二区| 日本一区二区三区四区在线视频| 国产福利91精品| 国产婷婷色一区二区三区|