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

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

?? orderedbag.cs

?? C#寫的類似于STL的集合類,首先是C#編寫,可以用于.net變程.
?? CS
?? 第 1 頁 / 共 5 頁
字號:
?//******************************
// 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.Generic;
using System.Collections;

// CONSIDER: RemoveIdentical to remove an identical item only. Can this be done with current RedBlack tree implementation? How
// CONSIDER: useful is it?

namespace Wintellect.PowerCollections
{
    /// <summary>
    /// OrderedBag&lt;T&gt; is a collection that contains items of type T. 
    /// The item are maintained in a sorted order. Unlike a OrderedSet, duplicate items (items that
    /// compare equal to each other) are allows in an OrderedBag.
    /// </summary>
    /// <remarks>
    /// <p>The items are compared in one of three ways. If T implements IComparable&lt;TKey&gt; or IComparable,
    /// then the CompareTo method of that interface will be used to compare items. Alternatively, a comparison
    /// function can be passed in either as a delegate, or as an instance of IComparer&lt;TKey&gt;.</p>
    /// <p>OrderedBag is implemented as a balanced binary tree. Inserting, deleting, and looking up an
    /// an element all are done in log(N) + M time, where N is the number of keys in the tree, and M is the current number
    /// of copies of the element being handled.</p>
    /// <p><see cref="Bag&lt;T&gt;"/> is similar, but uses hashing instead of comparison, and does not maintain
    /// the keys in sorted order.</p>
    ///</remarks>
    ///<seealso cref="Bag&lt;T&gt;"/>
    [Serializable]
    public class OrderedBag<T> : CollectionBase<T>, ICloneable
    {
        // The comparer used to compare items. 
        private IComparer<T> comparer;

        // The red-black tree that actually does the work of storing the items.
        private RedBlackTree<T> tree;

        #region Constructors

        /// <summary>
        /// Creates a new OrderedBag. The T must implement IComparable&lt;T&gt;
        /// or IComparable. 
        /// The CompareTo method of this interface will be used to compare items in this bag.
        /// </summary>
        ///<remarks>
        /// Items that are null are permitted, and will be sorted before all other items.
        ///</remarks>
        /// <exception cref="InvalidOperationException">T does not implement IComparable&lt;TKey&gt;.</exception>
        public OrderedBag(): 
            this(Comparers.DefaultComparer<T>())
        {
        }

        /// <summary>
        /// Creates a new OrderedBag. The passed delegate will be used to compare items in this bag.
        /// </summary>
        /// <param name="comparison">A delegate to a method that will be used to compare items.</param>
        public OrderedBag(Comparison<T> comparison) :
            this(Comparers.ComparerFromComparison<T>(comparison))
        {
        }

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

            this.comparer = comparer;
            tree = new RedBlackTree<T>(comparer);
        }

        /// <summary>
        /// Creates a new OrderedBag. The T must implement IComparable&lt;T&gt;
        /// or IComparable. 
        /// The CompareTo method of this interface will be used to compare items in this bag. The bag is
        /// initialized with all the items in the given collection.
        /// </summary>
        ///<remarks>
        /// Items that are null are permitted, and will be sorted before all other items.
        ///</remarks>
        /// <param name="collection">A collection with items to be placed into the OrderedBag.</param>
        /// <exception cref="InvalidOperationException">T does not implement IComparable&lt;TKey&gt;.</exception>
        public OrderedBag(IEnumerable<T> collection): 
            this(collection, Comparers.DefaultComparer<T>())
        {
        }

        /// <summary>
        /// Creates a new OrderedBag. The passed delegate will be used to compare items in this bag.
        /// The bag is initialized with all the items in the given collection.
        /// </summary>
        /// <param name="collection">A collection with items to be placed into the OrderedBag.</param>
        /// <param name="comparison">A delegate to a method that will be used to compare items.</param>
        public OrderedBag(IEnumerable<T> collection, Comparison<T> comparison):
            this(collection, Comparers.ComparerFromComparison<T>(comparison))
        {
        }

        /// <summary>
        /// Creates a new OrderedBag. The Compare method of the passed comparison object
        /// will be used to compare items in this bag. The bag is
        /// initialized with all the items in the given collection.
        /// </summary>
        /// <remarks>
        /// The GetHashCode and Equals methods of the provided IComparer&lt;T&gt; will never
        /// be called, and need not be implemented.
        /// </remarks>
        /// <param name="collection">A collection with items to be placed into the OrderedBag.</param>
        /// <param name="comparer">An instance of IComparer&lt;T&gt; that will be used to compare items.</param>
        public OrderedBag(IEnumerable<T> collection, IComparer<T> comparer):
            this(comparer)
        {
            AddMany(collection);
        }

        /// <summary>
        /// Creates a new OrderedBag given a comparer and a tree that contains the data. Used
        /// internally for Clone.
        /// </summary>
        /// <param name="comparer">Comparer for the bag.</param>
        /// <param name="tree">Data for the bag.</param>
        private OrderedBag(IComparer<T> comparer, RedBlackTree<T> tree) 
        {
            this.comparer = comparer;
            this.tree = tree;
        }

        #endregion Constructors

        #region Cloning

        /// <summary>
        /// Makes a shallow clone of this bag; i.e., if items of the
        /// bag are reference types, then they are not cloned. If T is a value type,
        /// then each element is copied as if by simple assignment.
        /// </summary>
        /// <remarks>Cloning the bag takes time O(N), where N is the number of items in the bag.</remarks>
        /// <returns>The cloned bag.</returns>
        object ICloneable.Clone()
        {
            return this.Clone();
        }

        /// <summary>
        /// Makes a shallow clone of this bag; i.e., if items of the
        /// bag are reference types, then they are not cloned. If T is a value type,
        /// then each element is copied as if by simple assignment.
        /// </summary>
        /// <remarks>Cloning the bag takes time O(N), where N is the number of items in the bag.</remarks>
        /// <returns>The cloned bag.</returns>
        public OrderedBag<T> Clone()
        {
            OrderedBag<T> newBag = new OrderedBag<T>(comparer, tree.Clone());
            return newBag;
        }

        /// <summary>
        /// Makes a deep clone of this bag. A new bag is created with a clone of
        /// each element of this bag, by calling ICloneable.Clone on each element. If T is
        /// a value type, then each element is copied as if by simple assignment.
        /// </summary>
        /// <remarks><para>If T is a reference type, it must implement
        /// ICloneable. Otherwise, an InvalidOperationException is thrown.</para>
        /// <para>Cloning the bag takes time O(N log N), where N is the number of items in the bag.</para></remarks>
        /// <returns>The cloned bag.</returns>
        /// <exception cref="InvalidOperationException">T is a reference type that does not implement ICloneable.</exception>
        public OrderedBag<T> CloneContents()
        {
            bool itemIsValueType;
            if (!Util.IsCloneableType(typeof(T), out itemIsValueType))
                throw new InvalidOperationException(string.Format(Strings.TypeNotCloneable, typeof(T).FullName));

            OrderedBag<T> clone = new OrderedBag<T>(comparer);

            // Clone each item, and add it to the new ordered bag.
            foreach (T item in this) {
                T itemClone;

                if (itemIsValueType)
                    itemClone = item;
                else {
                    if (item == null)
                        itemClone = default(T);    // Really null, because we know T is a reference type
                    else
                        itemClone = (T)(((ICloneable)item).Clone());
                }

                clone.Add(itemClone);
            }

            return clone;
        }

        #endregion Cloning

        #region Basic collection containment

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

        /// <summary>
        /// Returns the number of items in the bag.
        /// </summary>
        /// <remarks>The size of the bag is returned in constant time.</remarks>
        /// <value>The number of items in the bag.</value>
        public sealed override int Count
        {
            get
            {
                return tree.ElementCount;
            }
        }

        /// <summary>
        /// Returns the number of copies of <paramref name="item"/> in the bag. More precisely, returns
        /// the number of items in the bag that compare equal to <paramref name="item"/>.
        /// </summary>
        /// <remarks>NumberOfCopies() takes time O(log N + M), where N is the total number of items in the
        /// bag, and M is the number of copies of <paramref name="item"/> in the bag.</remarks>
        /// <param name="item">The item to search for in the bag.</param>
        /// <returns>The number of items in the bag that compare equal to <paramref name="item"/>.</returns>
        public int NumberOfCopies(T item)
        {
            return tree.CountRange(tree.EqualRangeTester(item));
        }

        /// <summary>
        /// Returns an enumerator that enumerates all the items in the bag. 
        /// The items are enumerated in sorted order.
        /// </summary>
        /// <remarks>
        /// <p>Typically, this method is not called directly. Instead the "foreach" statement is used
        /// to enumerate the items, which uses this method implicitly.</p>
        /// <p>If an item is added to or deleted from the bag while it is being enumerated, then 
        /// the enumeration will end with an InvalidOperationException.</p>
        /// <p>Enumeration all the items in the bag takes time O(N), where N is the number
        /// of items in the bag.</p>
        /// </remarks>
        /// <returns>An enumerator for enumerating all the items in the OrderedBag.</returns>		
        public sealed override IEnumerator<T> GetEnumerator()
        {
            return tree.GetEnumerator();
        }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费色视频| 亚洲在线成人精品| 精品视频色一区| 国产福利一区在线| 日韩成人精品视频| 一个色在线综合| 中文字幕av一区 二区| 26uuu欧美日本| 成人性视频网站| 亚洲影院免费观看| 精品国产麻豆免费人成网站| 一区二区三区四区在线播放 | 精品免费99久久| 亚洲国产中文字幕| 伊人性伊人情综合网| 精品国产乱码久久久久久久久 | 制服丝袜亚洲精品中文字幕| 成人av网址在线观看| 狂野欧美性猛交blacked| 亚洲精品乱码久久久久久黑人| 精品国产一区二区在线观看| 欧美日韩在线亚洲一区蜜芽| 91女厕偷拍女厕偷拍高清| 国产老女人精品毛片久久| 久久99精品网久久| 免费观看久久久4p| 婷婷激情综合网| 亚洲福利视频一区| 一区二区三区美女| 亚洲猫色日本管| 亚洲欧洲日产国产综合网| 日本一区二区三区高清不卡| 欧美mv日韩mv国产| 精品人在线二区三区| 日韩色视频在线观看| 91.麻豆视频| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲伊人色欲综合网| 一区二区三区国产精华| 亚洲人成网站影音先锋播放| 中文字幕亚洲电影| **欧美大码日韩| 亚洲欧美一区二区三区极速播放| 中文字幕一区二区三区不卡在线| 国产精品视频第一区| 国产精品久久久久桃色tv| 国产精品久久久久久久浪潮网站 | 91理论电影在线观看| 91麻豆精品在线观看| 91福利资源站| 中文字幕一区二区5566日韩| 欧美嫩在线观看| 国产午夜亚洲精品理论片色戒| 欧美一区二区三区日韩视频| 日韩视频在线你懂得| 欧美综合一区二区| 日本精品一级二级| 91视视频在线直接观看在线看网页在线看| 麻豆成人综合网| 蜜臀a∨国产成人精品| 国产白丝精品91爽爽久久| 婷婷激情综合网| 亚洲午夜久久久久久久久电影院| 亚洲国产精品人人做人人爽| 日韩专区一卡二卡| 国产精品亚洲一区二区三区在线| 成人aaaa免费全部观看| 欧美性色黄大片手机版| 精品久久久久一区二区国产| 国产精品第四页| 五月激情六月综合| 国产黄人亚洲片| 在线免费观看日韩欧美| 日韩午夜av电影| 中文字幕一区二区三| 午夜国产精品一区| 国产九色sp调教91| 欧美亚洲综合色| 国产丝袜欧美中文另类| 中文字幕第一页久久| 亚洲电影你懂得| 国产91在线观看| 欧美日韩另类一区| 国产精品久久三区| 蜜臀国产一区二区三区在线播放| 成人午夜精品在线| 欧美一区二区私人影院日本| 中日韩av电影| 日本成人超碰在线观看| 不卡的av网站| 欧美成人艳星乳罩| 一区二区三区免费在线观看| 国产在线国偷精品产拍免费yy| 色综合天天综合网天天狠天天| 欧美电视剧在线看免费| 亚洲视频综合在线| 国产一区999| 91精品国产一区二区三区蜜臀| 中文字幕av不卡| 精品午夜久久福利影院| 欧美亚洲禁片免费| 国产精品视频麻豆| 国产美女一区二区| 制服丝袜激情欧洲亚洲| 亚洲另类色综合网站| 国产精品一区在线观看乱码 | 欧美丝袜丝交足nylons图片| 久久综合成人精品亚洲另类欧美| 亚洲国产欧美日韩另类综合| 国产成人精品aa毛片| 日韩欧美中文字幕精品| 久久久久99精品一区| 日本不卡一区二区三区高清视频| 亚洲欧洲日产国产综合网| 国产成人小视频| 亚洲一区二区三区中文字幕| 国产精品996| 国产拍揄自揄精品视频麻豆| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美在线一区二区三区| 亚洲最大成人综合| 在线观看成人小视频| 国产一区二区免费在线| 欧美一区二区黄| 亚洲成年人网站在线观看| 91视频在线观看免费| 中文字幕第一区综合| 国产精品一级片| 精品免费日韩av| 国产综合色产在线精品| 精品sm捆绑视频| 久久99精品一区二区三区| 日韩欧美一级精品久久| 裸体健美xxxx欧美裸体表演| 欧美二区在线观看| 日韩—二三区免费观看av| 9191精品国产综合久久久久久| 亚洲国产cao| 欧美日本一道本| 蜜桃av噜噜一区二区三区小说| 9191国产精品| 久久99日本精品| xfplay精品久久| 成人网在线播放| 国产精品传媒入口麻豆| 91最新地址在线播放| 亚洲精选一二三| 欧美性生活久久| 日日欢夜夜爽一区| 欧美哺乳videos| 丰满亚洲少妇av| 中文字幕亚洲综合久久菠萝蜜| 99久久综合狠狠综合久久| 亚洲蜜臀av乱码久久精品| 欧美伊人久久久久久久久影院| 亚洲h精品动漫在线观看| 制服丝袜av成人在线看| 精品影院一区二区久久久| 久久久99精品免费观看| gogogo免费视频观看亚洲一| 亚洲综合在线观看视频| 欧美日本在线播放| 精品一区二区免费在线观看| 亚洲国产精品高清| 欧美主播一区二区三区美女| 免费成人性网站| 国产欧美在线观看一区| 97国产精品videossex| 天堂av在线一区| 久久精品人人爽人人爽| 色成年激情久久综合| 看电影不卡的网站| 亚洲欧美另类小说| 日韩一区二区在线观看视频| 国产成人av福利| 亚洲午夜视频在线观看| 久久午夜色播影院免费高清| 91欧美激情一区二区三区成人| 免费看精品久久片| 中文字幕日本不卡| 欧美一二区视频| 麻豆精品视频在线观看视频| 丝袜亚洲另类丝袜在线| 欧美人伦禁忌dvd放荡欲情| 久久综合久久久久88| 日本vs亚洲vs韩国一区三区二区 | 日韩欧美在线网站| 日韩精品一区二区三区视频 | 国产成人精品综合在线观看 | 精品一区免费av| 亚洲免费在线视频| 欧美成人激情免费网| www.日韩av| 麻豆国产欧美日韩综合精品二区| 国产精品国产三级国产aⅴ无密码| 欧美日本乱大交xxxxx| 9人人澡人人爽人人精品| 久久精品国产精品亚洲红杏| 亚洲特级片在线| 久久精品欧美一区二区三区不卡|