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

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

?? 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();
        }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美大片拔萝卜| 欧美日韩国产大片| 国产精品一区不卡| 精品一区二区三区av| 日日夜夜免费精品视频| 美女在线一区二区| 久草在线在线精品观看| 国产成人精品免费| 91在线视频播放| 在线成人小视频| 国产欧美日韩不卡| 亚洲国产综合视频在线观看| 久久国内精品自在自线400部| 麻豆精品国产传媒mv男同 | 国产麻豆视频精品| youjizz久久| 久久综合色鬼综合色| 亚洲美女偷拍久久| 国产精品小仙女| 欧美日韩在线精品一区二区三区激情 | 狠狠v欧美v日韩v亚洲ⅴ| 成人黄色综合网站| 日韩免费电影一区| 一区二区三区日韩精品视频| 国产麻豆精品95视频| 欧美日本高清视频在线观看| 国产精品久久午夜夜伦鲁鲁| 日韩av中文字幕一区二区| 99re热这里只有精品免费视频| 欧美一区二区三区不卡| 综合电影一区二区三区| 国产麻豆精品视频| 精品国产1区2区3区| 日韩中文欧美在线| 欧美日韩精品福利| 性欧美大战久久久久久久久| 国产成人免费高清| 日本一区二区免费在线| 精品亚洲欧美一区| 久久婷婷久久一区二区三区| 天天综合色天天| 欧美大白屁股肥臀xxxxxx| 偷拍一区二区三区| 日韩美女一区二区三区四区| 免费在线欧美视频| 国产视频911| av电影在线观看完整版一区二区| 国产精品视频一二三| 99re亚洲国产精品| 亚洲一区二区成人在线观看| 欧美日韩一区视频| 精品无人区卡一卡二卡三乱码免费卡| 欧美一级高清片| 成人黄色综合网站| 亚洲二区在线视频| 精品国产乱码久久久久久浪潮| 九一久久久久久| 亚洲日本va午夜在线影院| 欧美日本在线看| 不卡欧美aaaaa| 亚洲1区2区3区4区| 亚洲欧美电影院| 日韩精品一区在线观看| 99久久久久久| 精品在线视频一区| 亚洲伊人色欲综合网| 国产日韩欧美精品一区| 91精品啪在线观看国产60岁| www.欧美精品一二区| 激情图区综合网| 亚洲综合色噜噜狠狠| 国产精品久久午夜夜伦鲁鲁| 欧美xxxxx裸体时装秀| 欧美三片在线视频观看 | 日韩视频一区在线观看| 国产精品护士白丝一区av| 欧美久久久久久久久中文字幕| 成人a级免费电影| 国产米奇在线777精品观看| 亚洲一区在线观看免费观看电影高清 | 欧美xxxxxxxx| 欧美一区二区三区播放老司机| 欧美午夜精品一区二区三区| 成人午夜视频免费看| 国产一区二区伦理片| 久久99精品久久久久久动态图| 夜夜嗨av一区二区三区四季av| 国产精品婷婷午夜在线观看| 亚洲国产精品黑人久久久| 国产女人18水真多18精品一级做| 精品国产91乱码一区二区三区 | 亚洲成人动漫一区| 亚洲福利视频导航| 蜜臀av性久久久久蜜臀aⅴ| 蜜臀久久久久久久| 国产精品影视在线观看| 成人在线综合网站| 91亚洲精品久久久蜜桃| 欧美日韩视频一区二区| 51精品秘密在线观看| 精品美女一区二区三区| 国产亚洲精品精华液| 亚洲在线观看免费| 黄一区二区三区| 一本久久a久久免费精品不卡| 欧美亚洲动漫精品| 久久久久久免费网| 污片在线观看一区二区| 成人国产精品免费| 日韩午夜精品电影| 亚洲欧美韩国综合色| 国产乱码精品一区二区三区五月婷| 成人亚洲一区二区一| 欧美日韩免费不卡视频一区二区三区 | 欧美中文字幕亚洲一区二区va在线 | 日韩免费福利电影在线观看| 亚洲欧美影音先锋| 国产一区二区0| 欧美一级一级性生活免费录像| 国产精品亲子伦对白| 久久精品国产99国产| 色综合久久久久综合99| 久久精品亚洲国产奇米99| 日韩精品午夜视频| 欧美无乱码久久久免费午夜一区| 国产性天天综合网| 韩国精品主播一区二区在线观看| 欧美日韩一区不卡| 亚洲永久免费av| 色综合婷婷久久| 国产精品不卡一区二区三区| 夫妻av一区二区| 久久久777精品电影网影网 | 日韩一级大片在线| 日韩精品五月天| 欧美一级片免费看| 免费观看久久久4p| 亚洲精品在线三区| 国产成人久久精品77777最新版本| 26uuu色噜噜精品一区二区| 久久www免费人成看片高清| 精品国产精品一区二区夜夜嗨| 日本美女视频一区二区| 日韩三级视频在线看| 韩国精品一区二区| 国产精品伦理在线| 欧美日韩你懂的| 国产一二精品视频| 亚洲精品老司机| 欧美一区午夜精品| 成人性视频免费网站| 无码av中文一区二区三区桃花岛| 欧美tk—视频vk| 91免费视频网| 久久97超碰国产精品超碰| 亚洲色图一区二区| 精品久久久久久久久久久院品网 | 亚洲成人激情综合网| 久久久久久久久岛国免费| 91伊人久久大香线蕉| 日韩电影免费一区| 国产精品传媒视频| 久久久综合精品| 欧美疯狂做受xxxx富婆| 波多野结衣视频一区| 激情综合色播五月| 视频一区免费在线观看| 亚洲免费在线电影| 国产精品视频麻豆| 久久精品亚洲麻豆av一区二区| 91高清视频在线| 亚洲男人都懂的| 欧美综合色免费| 日本三级亚洲精品| 夜夜嗨av一区二区三区网页| 国产亚洲人成网站| 国产日韩欧美综合在线| 欧美精品一区二区三区很污很色的 | 99久久久久久99| 99re热这里只有精品视频| 9l国产精品久久久久麻豆| 波多野结衣欧美| 色一情一乱一乱一91av| 91亚洲国产成人精品一区二三 | 国产亚洲精品免费| 国产精品成人一区二区艾草 | 91在线观看地址| 欧美色图在线观看| 日韩欧美专区在线| 欧美sm美女调教| 国产精品网站在线| 亚洲高清在线精品| 精品一区二区三区在线观看 | 国产精品高潮呻吟| 一区二区三区加勒比av| 香蕉成人啪国产精品视频综合网| 国产在线麻豆精品观看| 97精品久久久午夜一区二区三区| 欧洲色大大久久| 欧美高清在线视频|