亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产亚洲精品aa午夜观看| 卡一卡二国产精品| 蜜臀国产一区二区三区在线播放| 高清beeg欧美| 精品国产一区二区精华| 亚洲精品久久嫩草网站秘色| 国产精品亚洲午夜一区二区三区| 一本大道av伊人久久综合| 国产亚洲一区二区三区四区| 日韩精品三区四区| 欧美综合在线视频| 自拍偷自拍亚洲精品播放| 国产盗摄一区二区三区| www国产精品av| 免费日韩伦理电影| 欧美顶级少妇做爰| 亚洲午夜电影在线观看| 在线观看免费成人| 亚洲欧美日韩精品久久久久| 成人黄色av电影| 国产调教视频一区| 国产电影精品久久禁18| 久久精品欧美日韩| 国产成人免费视频网站 | 国产精品久线在线观看| 国产在线不卡一卡二卡三卡四卡| 欧美理论片在线| 亚洲r级在线视频| 欧美午夜片在线看| 一区二区激情小说| 91丨九色丨国产丨porny| 国产精品久久久久四虎| 91女神在线视频| 亚洲激情在线激情| 91福利视频久久久久| 一区二区三区自拍| 欧美视频一区二区三区四区| 亚洲一级二级三级在线免费观看| 欧美在线制服丝袜| 亚洲一区精品在线| 91精品欧美福利在线观看| 日韩电影一二三区| 久久久欧美精品sm网站| 成人午夜视频在线观看| 一区二区三区四区中文字幕| 欧美精选午夜久久久乱码6080| 日本vs亚洲vs韩国一区三区二区| 日韩一级大片在线观看| 国产一区高清在线| 亚洲人成网站影音先锋播放| 欧美怡红院视频| 久久成人av少妇免费| 国产婷婷色一区二区三区四区| 91丨九色丨国产丨porny| 午夜精品视频在线观看| 久久夜色精品国产欧美乱极品| 成人免费视频视频| 亚洲福利一区二区三区| 久久综合久久综合亚洲| 91网上在线视频| 久久精品国产99久久6| 国产精品美女久久久久久2018| 欧美亚洲高清一区| 韩国v欧美v日本v亚洲v| 亚洲欧美日韩国产手机在线| 在线综合视频播放| 成人av影院在线| 免费在线观看不卡| 亚洲人成网站在线| 久久久精品国产99久久精品芒果| 91国产精品成人| 国产在线精品免费| 亚洲成人黄色影院| 国产精品久久久久久久久果冻传媒 | 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 91久久精品日日躁夜夜躁欧美| 日本欧洲一区二区| 亚洲女人****多毛耸耸8| 精品久久一区二区| 在线观看区一区二| www.亚洲精品| 国产精品系列在线观看| 亚洲国产日日夜夜| 中文字幕在线播放不卡一区| 日韩一区和二区| 欧美调教femdomvk| 成人福利视频在线| 国产精品一区二区久久精品爱涩| 午夜精彩视频在线观看不卡| 亚洲蜜臀av乱码久久精品蜜桃| 久久久99精品久久| 日韩免费观看高清完整版在线观看| 色哟哟国产精品| 成人免费观看视频| 风间由美性色一区二区三区| 国产精品自在在线| 久久99九九99精品| 五月激情综合婷婷| 亚洲一区二区视频在线观看| 1000部国产精品成人观看| 国产日韩v精品一区二区| 欧美tk—视频vk| 日韩午夜在线观看| 91精品国产黑色紧身裤美女| 欧美日韩一区精品| 欧美日韩成人激情| 欧美日韩国产综合视频在线观看| 欧美亚洲一区二区三区四区| 欧美午夜视频网站| 精品污污网站免费看| 欧洲亚洲国产日韩| 在线免费观看一区| 在线观看日韩一区| 欧美日韩一区二区三区在线| 欧美色综合影院| 欧美性做爰猛烈叫床潮| 在线日韩国产精品| 欧美日韩一区二区电影| 欧美精品一二三区| 欧美久久久久免费| 日韩午夜电影av| 精品国产三级a在线观看| 久久久久久日产精品| 国产视频在线观看一区二区三区| 中文一区在线播放| 国产精品免费观看视频| 亚洲欧美日韩国产综合在线| 亚洲一区二区欧美| 日本人妖一区二区| 国产精品88888| 91麻豆自制传媒国产之光| 欧美性大战xxxxx久久久| 4438x亚洲最大成人网| 欧美精品一区二区精品网| 中文字幕精品综合| 亚洲裸体在线观看| 无码av免费一区二区三区试看 | 一区二区三区精品视频| 亚洲一区在线观看免费| 青娱乐精品在线视频| 激情欧美一区二区三区在线观看| 国产成人一区在线| 在线视频综合导航| 精品国产91九色蝌蚪| 最新热久久免费视频| 日韩精品一二三区| 丁香六月久久综合狠狠色| 欧美视频在线观看一区二区| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 国产亚洲欧洲997久久综合| 成人欧美一区二区三区黑人麻豆 | 久久久国产一区二区三区四区小说 | 日韩和欧美一区二区| 国产一区二区三区| 在线观看视频一区二区欧美日韩| 日韩小视频在线观看专区| 亚洲婷婷综合久久一本伊一区| 日韩国产精品久久| 99re免费视频精品全部| 欧美电影影音先锋| 自拍视频在线观看一区二区| 奇米影视7777精品一区二区| 成人免费三级在线| 91精品在线观看入口| 亚洲欧美日韩中文播放| 精品一区二区三区在线播放| 欧美系列一区二区| 国产精品第13页| 国产一区二区三区香蕉| 91.com在线观看| 亚洲精品国产第一综合99久久| 国模无码大尺度一区二区三区| 欧美日韩一区在线| 亚洲欧美激情在线| 成人黄动漫网站免费app| 精品国产乱码久久久久久久久| 亚洲高清中文字幕| 91行情网站电视在线观看高清版| 国产欧美一区二区精品忘忧草| 日本va欧美va欧美va精品| 欧美综合久久久| 一区二区成人在线| 91在线精品一区二区| 中文一区一区三区高中清不卡| 精品一区二区三区的国产在线播放 | 免费一区二区视频| 欧美日韩dvd在线观看| 亚洲午夜久久久久久久久电影网| 99久久亚洲一区二区三区青草| 国产精品美女久久久久aⅴ国产馆| 国产原创一区二区| 久久综合资源网| 国产精品99精品久久免费| 精品久久久久av影院| 免费高清不卡av| 日韩精品在线看片z| 久久99国产精品免费| 精品粉嫩超白一线天av| 久久精品99国产精品日本| 精品国产百合女同互慰|