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

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

?? bag.cs

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


namespace Wintellect.PowerCollections
{
    /// <summary>
    /// Bag&lt;T&gt; is a collection that contains items of type T. 
    /// Unlike a Set, duplicate items (items that compare equal to each other) are allowed in an Bag. 
    /// </summary>
    /// <remarks>
    /// <p>The items are compared in one of two ways. If T implements IComparable&lt;T&gt; 
    /// then the Equals method of that interface will be used to compare items, otherwise the Equals
    /// method from Object will be used. Alternatively, an instance of IComparer&lt;T&gt; can be passed
    /// to the constructor to use to compare items.</p>
    /// <p>Bag is implemented as a hash table. Inserting, deleting, and looking up an
    /// an element all are done in approximately constant time, regardless of the number of items in the bag.</p>
    /// <p>When multiple equal items are stored in the bag, they are stored as a representative item and a count. 
    /// If equal items can be distinguished, this may be noticable. For example, if a case-insensitive
    /// comparer is used with a Bag&lt;string&gt;, and both "hello", and "HELLO" are added to the bag, then the
    /// bag will appear to contain two copies of "hello" (the representative item).</p>
    /// <p><see cref="OrderedBag&lt;T&gt;"/> is similar, but uses comparison instead of hashing, maintain
    /// the items in sorted order, and stores distinct copies of items that compare equal.</p>
    ///</remarks>
    ///<seealso cref="OrderedBag&lt;T&gt;"/>
    [Serializable]
    public class Bag<T> : CollectionBase<T>, ICloneable
    {
        // The comparer used to compare KeyValuePairs. Equals and GetHashCode are used.
        private IEqualityComparer<KeyValuePair<T,int>> equalityComparer;

        // The comparer used to compare items. Kept just for the Comparer property. 
        private IEqualityComparer<T> keyEqualityComparer;

        // The hash that actually does the work of storing the items. Each item is
        // stored as a representative item, and a count.
        private Hash<KeyValuePair<T, int>> hash;   

        // The total number of items stored in the bag.
        private int count;

        /// <summary>
        /// Helper function to create a new KeyValuePair struct with an item and a count.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="count">The number of appearances.</param>
        /// <returns>A new KeyValuePair.</returns>
        private static KeyValuePair<T, int> NewPair(T item, int count)
        {
            KeyValuePair<T, int> pair = new KeyValuePair<T,int>(item, count);
            return pair;
        }

        /// <summary>
        /// Helper function to create a new KeyValuePair struct with a count of zero.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>A new KeyValuePair.</returns>
        private static KeyValuePair<T, int> NewPair(T item)
        {
            KeyValuePair<T, int> pair = new KeyValuePair<T, int>(item, 0);
            return pair;
        }

        #region Constructors

        /// <summary>
        /// Creates a new Bag. 
        /// </summary>
        ///<remarks>
        /// Items that are null are permitted.
        ///</remarks>
        public Bag(): 
            this(EqualityComparer<T>.Default)
        {
        }

        /// <summary>
        /// Creates a new Bag. The Equals and GetHashCode methods of the passed comparison object
        /// will be used to compare items in this bag for equality.
        /// </summary>
        /// <param name="equalityComparer">An instance of IEqualityComparer&lt;T&gt; that will be used to compare items.</param>
        public Bag(IEqualityComparer<T> equalityComparer)
        {
            if (equalityComparer == null)
                throw new ArgumentNullException("equalityComparer");

            this.keyEqualityComparer = equalityComparer;
            this.equalityComparer = Comparers.EqualityComparerKeyValueFromComparerKey<T, int>(equalityComparer);
            this.hash = new Hash<KeyValuePair<T, int>>(this.equalityComparer);
        }

        /// <summary>
        /// Creates a new Bag. The bag is
        /// initialized with all the items in the given collection.
        /// </summary>
        ///<remarks>
        /// Items that are null are permitted.
        ///</remarks>
        /// <param name="collection">A collection with items to be placed into the Bag.</param>
        public Bag(IEnumerable<T> collection): 
            this(collection, EqualityComparer<T>.Default)
        {
        }

        /// <summary>
        /// Creates a new Bag. The Equals and GetHashCode methods 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>
        /// <param name="collection">A collection with items to be placed into the Bag.</param>
        /// <param name="equalityComparer">An instance of IEqualityComparer&lt;T&gt; that will be used to compare items.</param>
        public Bag(IEnumerable<T> collection, IEqualityComparer<T> equalityComparer)
            : this(equalityComparer)
        {
            AddMany(collection);
        }

        /// <summary>
        /// Creates a new Bag given a comparer and a hash that contains the data. Used
        /// internally for Clone.
        /// </summary>
        /// <param name="equalityComparer">IEqualityComparer for the bag.</param>
        /// <param name="keyEqualityComparer">IEqualityComparer for the key.</param>
        /// <param name="hash">Data for the bag.</param>
        /// <param name="count">Size of the bag.</param>
        private Bag(IEqualityComparer<KeyValuePair<T, int>> equalityComparer, IEqualityComparer<T> keyEqualityComparer, Hash<KeyValuePair<T,int>> hash, int count)
        {
            this.equalityComparer = equalityComparer;
            this.keyEqualityComparer = keyEqualityComparer;
            this.hash = hash;
            this.count = count;
        }

        #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 unquie items in the bag.</remarks>
        /// <returns>The cloned bag.</returns>
        public Bag<T> Clone()
        {
            Bag<T> newBag = new Bag<T>(equalityComparer, keyEqualityComparer, hash.Clone(null), count);
            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 Bag<T> CloneContents()
        {
            bool itemIsValueType;
            if (!Util.IsCloneableType(typeof(T), out itemIsValueType))
                throw new InvalidOperationException(string.Format(Strings.TypeNotCloneable, typeof(T).FullName));

            Hash<KeyValuePair<T,int>> newHash = new Hash<KeyValuePair<T,int>>(equalityComparer);

            // Clone each item, and add it to the new ordered bag.
            foreach (KeyValuePair<T, int> pair in hash) {
                KeyValuePair<T, int> newPair, dummy;
                T newKey;

                if (!itemIsValueType && pair.Key != null)
                    newKey = (T)(((ICloneable)pair.Key).Clone());
                else
                    newKey = pair.Key;

                newPair = NewPair(newKey, pair.Value);

                newHash.Insert(newPair, true, out dummy);
            }

            return new Bag<T>(equalityComparer, keyEqualityComparer, newHash, count); 
        }

        #endregion Cloning

        #region Basic collection containment

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

        /// <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 count;
            }
        }

        /// <summary>
        /// Returns the number of copies of <paramref name="item"/> in the bag. 
        /// </summary>
        /// <remarks>NumberOfCopies() takes approximately constant time, no matter how many items
        /// are stored 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)
        {
            KeyValuePair<T, int> foundPair;
            if (hash.Find(NewPair(item), false, out foundPair)) 
                return foundPair.Value;
            else
                return 0;
        }

        /// <summary>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品亚洲专一区二区三区 | 91精品国产综合久久福利| 亚洲精品国产无天堂网2021| 色综合久久中文字幕综合网| 亚洲精品ww久久久久久p站 | 日韩午夜电影av| 九九久久精品视频| 国产片一区二区| av日韩在线网站| 亚洲一线二线三线视频| 欧美日韩国产小视频在线观看| 美女视频网站黄色亚洲| 欧美国产日产图区| 一本色道久久综合亚洲91| 天堂av在线一区| 久久精品日韩一区二区三区| 一本久道中文字幕精品亚洲嫩| 午夜激情久久久| 国产亚洲短视频| 在线视频国产一区| 另类小说欧美激情| 国产精品国产三级国产aⅴ中文 | 日本欧美一区二区三区乱码| 国产清纯白嫩初高生在线观看91| 一本色道久久综合狠狠躁的推荐 | 久久国产精品区| 中文字幕高清不卡| 欧美狂野另类xxxxoooo| 国产福利一区二区| 亚洲亚洲人成综合网络| 精品国产123| 在线观看91视频| 福利视频网站一区二区三区| 亚洲第一激情av| 国产精品高清亚洲| 日韩女优av电影| 色国产综合视频| 国产精品一区二区无线| 亚洲不卡一区二区三区| 欧美韩国日本综合| 日韩一区二区在线免费观看| 色诱亚洲精品久久久久久| 国产在线视频不卡二| 一级日本不卡的影视| 中文子幕无线码一区tr| 91麻豆精品国产91久久久久久| 99国产精品国产精品久久| 国产一区二区三区香蕉 | 精品国产伦一区二区三区免费| 91色.com| 国产精品白丝jk白祙喷水网站| 日本在线播放一区二区三区| 亚洲另类在线一区| 国产精品美女久久久久久久网站| 日韩一级视频免费观看在线| 欧美挠脚心视频网站| 一本高清dvd不卡在线观看| 成人18精品视频| 国产精品一卡二卡在线观看| 免费成人在线影院| 偷拍亚洲欧洲综合| 亚洲成人免费av| 亚洲一卡二卡三卡四卡五卡| 亚洲免费伊人电影| 国产精品超碰97尤物18| 欧美激情一二三区| 国产精品污www在线观看| 国产欧美一区二区三区网站| 久久精品综合网| 久久新电视剧免费观看| www国产亚洲精品久久麻豆| 欧美mv日韩mv国产网站| 欧美tk丨vk视频| 精品乱码亚洲一区二区不卡| 欧美一区二区免费观在线| 91精品综合久久久久久| 欧美一卡二卡在线| 日韩一区二区三区视频| 日韩一级二级三级精品视频| 日韩欧美国产一区二区三区| 日韩久久精品一区| 亚洲精品在线电影| 久久嫩草精品久久久精品| 久久久91精品国产一区二区三区| 国产午夜精品理论片a级大结局| 久久婷婷成人综合色| 欧美激情一二三区| 亚洲人123区| 亚洲高清免费视频| 免费高清在线视频一区·| 国产一区亚洲一区| 国产精品资源网| 91麻豆文化传媒在线观看| 欧洲激情一区二区| 欧美一区二区高清| 久久久久国产精品麻豆| 中文字幕在线不卡| 亚洲高清久久久| 国产在线播放一区二区三区| 风间由美性色一区二区三区| 在线免费观看日本一区| 欧美一级片在线| 国产精品久久久久久久午夜片| 尤物视频一区二区| 日本成人中文字幕在线视频| 国产精品1区2区3区在线观看| 2023国产一二三区日本精品2022| 国产精品卡一卡二| 性做久久久久久久免费看| 国产乱码精品一区二区三区av| 成人黄色国产精品网站大全在线免费观看 | 日韩欧美国产综合一区| 国产精品美女视频| 丝袜美腿亚洲色图| 成人做爰69片免费看网站| 欧美日韩三级在线| 国产日产亚洲精品系列| 亚洲自拍都市欧美小说| 国产一区二区在线看| 欧美在线观看视频一区二区| 久久嫩草精品久久久久| 亚洲一区二区三区中文字幕| 国产一区二区三区最好精华液| 欧美在线短视频| 欧美激情一区在线| 日本sm残虐另类| 91视频在线看| 久久久www免费人成精品| 亚洲午夜免费电影| 国产91高潮流白浆在线麻豆| 8x福利精品第一导航| 亚洲人一二三区| 精品国一区二区三区| 亚洲久草在线视频| 国产成人综合网站| 日韩你懂的在线播放| 亚洲另类在线制服丝袜| 成人网页在线观看| 精品国产乱码久久久久久图片| 午夜婷婷国产麻豆精品| 97精品电影院| 中国av一区二区三区| 国产一区二区三区久久悠悠色av| 欧美人xxxx| 亚洲综合另类小说| 97久久久精品综合88久久| 久久一区二区三区四区| 久久99久久99| 欧美一区二区精品| 性做久久久久久久免费看| 欧美午夜精品久久久久久孕妇 | 亚洲精品中文字幕在线观看| 国产东北露脸精品视频| 欧美成人乱码一区二区三区| 天堂久久久久va久久久久| 欧美日韩一区久久| 亚洲第一成人在线| 欧美性受xxxx| 亚洲成a人片综合在线| 色婷婷久久一区二区三区麻豆| 自拍偷拍欧美精品| 色综合久久综合网| 亚洲精品乱码久久久久久久久| 93久久精品日日躁夜夜躁欧美| 中文字幕中文字幕一区| 成人黄色综合网站| 国产精品久久久久四虎| eeuss鲁片一区二区三区| 中文字幕中文字幕一区| 99精品在线观看视频| 亚洲免费观看高清在线观看| 色哟哟在线观看一区二区三区| 亚洲色欲色欲www| 91精品1区2区| 亚洲成av人影院在线观看网| 4438x成人网最大色成网站| 蜜桃精品视频在线| www国产亚洲精品久久麻豆| 粉嫩久久99精品久久久久久夜| 欧美高清在线一区二区| 色婷婷激情综合| 亚洲成人资源在线| 日韩午夜电影av| 国产成人午夜精品5599| 国产91露脸合集magnet | 国产欧美精品在线观看| gogo大胆日本视频一区| 亚洲国产一区二区三区青草影视| 欧美日韩亚洲高清一区二区| 奇米精品一区二区三区四区| 久久精品亚洲乱码伦伦中文| 99re成人精品视频| 日韩综合一区二区| www国产成人| 一道本成人在线| 男人的j进女人的j一区| 日本一区二区三区电影| 在线视频中文字幕一区二区| 麻豆精品视频在线| 国产精品国产三级国产专播品爱网|