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

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

?? bag.cs

?? C#寫的類似于STL的集合類,首先是C#編寫,可以用于.net變程.
?? CS
?? 第 1 頁 / 共 4 頁
字號:
        /// Returns the representative item stored in the bag that is equal to
        /// the provided item. Also returns the number of copies of the item in the bag.
        /// </summary>
        /// <param name="item">Item to find in the bag.</param>
        /// <param name="representative">If one or more items equal to <paramref name="item"/> are present in the
        /// bag, returns the representative item. If no items equal to <paramref name="item"/> are stored in the bag, 
        /// returns <paramref name="item"/>.</param>
        /// <returns>The number of items equal to <paramref name="item"/> stored in the bag.</returns>
        public int GetRepresentativeItem(T item, out T representative)
        {
            KeyValuePair<T, int> foundPair;
            if (hash.Find(NewPair(item), false, out foundPair)) {
                representative = foundPair.Key;
                return foundPair.Value;
            }
            else {
                representative = item;
                return 0;
            }
        }

        /// <summary>
        /// Returns an enumerator that enumerates all the items in the bag. 
        /// If an item is present multiple times in the bag, the representative item is yielded by the
        /// enumerator multiple times. The order of enumeration is haphazard and may change.
        /// </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 Bag.</returns>		
        public sealed override IEnumerator<T> GetEnumerator()
        {
            foreach (KeyValuePair<T, int> pair in hash) {
                for (int i = 0; i < pair.Value; ++i)
                    yield return pair.Key;
            }
        }

        /// <summary>
        /// Determines if this bag contains an item equal to <paramref name="item"/>. The bag
        /// is not changed.
        /// </summary>
        /// <remarks>Searching the bag for an item takes time O(log N), where N is the number of items in the bag.</remarks>
        /// <param name="item">The item to search for.</param>
        /// <returns>True if the bag contains <paramref name="item"/>. False if the bag does not contain <paramref name="item"/>.</returns>
        public sealed override bool Contains(T item)
        {
            KeyValuePair<T, int> dummy;
            return hash.Find(NewPair(item), false, out dummy);
        }

        /// <summary>
        /// Enumerates all the items in the bag, but enumerates equal items
        /// just once, even if they occur multiple times in the bag.
        /// </summary>
        /// <remarks>If the bag is changed while items are being enumerated, the
        /// enumeration will terminate with an InvalidOperationException.</remarks>
        /// <returns>An IEnumerable&lt;T&gt; that enumerates the unique items.</returns>
        public IEnumerable<T> DistinctItems()
        {
            foreach (KeyValuePair<T, int> pair in hash) {
                yield return pair.Key;
            }
        }

        #endregion


        #region Adding elements

        /// <summary>
        /// Adds a new item to the bag. Since bags can contain duplicate items, the item 
        /// is added even if the bag already contains an item equal to <paramref name="item"/>. In
        /// this case, the count of items for the representative item is increased by one, but the existing
        /// represetative item is unchanged.
        /// </summary>
        /// <remarks>
        /// <para>Adding an item takes approximately constant time, regardless of the number of items in the bag.</para></remarks>
        /// <param name="item">The item to add to the bag.</param>
        public sealed override void Add(T item)
        {
            KeyValuePair<T, int> pair = NewPair(item, 1);
            KeyValuePair<T, int> existing, newPair;
            if (! hash.Insert(pair, false, out existing)) {
                // The item already existed, so update the count instead.
                newPair = NewPair(existing.Key, existing.Value + 1);
                hash.Insert(newPair, true, out pair);
            }
            ++count;
        }

        // CONSIDER: add an example to the documentation below.
        /// <summary>
        /// Adds a new item to the bag. Since bags can contain duplicate items, the item 
        /// is added even if the bag already contains an item equal to <paramref name="item"/>. In
        /// this case (unlike Add), the new item becomes the representative item.
        /// </summary>
        /// <remarks>
        /// <para>Adding an item takes approximately constant time, regardless of the number of items in the bag.</para></remarks>
        /// <param name="item">The item to add to the bag.</param>
        public void AddRepresentative(T item)
        {
            KeyValuePair<T, int> pair = NewPair(item, 1);
            KeyValuePair<T, int> existing, newPair;
            if (!hash.Insert(pair, false, out existing)) {
                // The item already existed, so update the count instead.
                newPair = NewPair(pair.Key, existing.Value + 1);
                hash.Insert(newPair, true, out pair);
            }
            ++count;
        }

        /// <summary>
        /// Changes the number of copies of an existing item in the bag, or adds the indicated number
        /// of copies of the item to the bag. 
        /// </summary>
        /// <remarks>
        /// <para>Changing the number of copies takes approximately constant time, regardless of the number of items in the bag.</para></remarks>
        /// <param name="item">The item to change the number of copies of. This may or may not already be present in the bag.</param>
        /// <param name="numCopies">The new number of copies of the item.</param>
        public void ChangeNumberOfCopies(T item, int numCopies)
        {
            if (numCopies == 0)
                RemoveAllCopies(item);
            else {
                KeyValuePair<T, int> dummy, existing, newPair;
                if (hash.Find(NewPair(item), false, out existing)) {
                    count += numCopies - existing.Value;
                    newPair = NewPair(existing.Key, numCopies);
                }
                else {
                    count += numCopies;
                    newPair = NewPair(item, numCopies);
                }
                hash.Insert(newPair, true, out dummy);
            }
        }

        /// <summary>
        /// Adds all the items in <paramref name="collection"/> to the bag. 
        /// </summary>
        /// <remarks>
        /// <para>Adding the collection takes time O(M log N), where N is the number of items in the bag, and M is the 
        /// number of items in <paramref name="collection"/>.</para></remarks>
        /// <param name="collection">A collection of items to add to the bag.</param>
        public void AddMany(IEnumerable<T> collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");

            // If we're adding ourselves, we need to copy to a separate array to avoid modification
            // during enumeration.
            if (this == collection)
                collection = this.ToArray();

            foreach (T item in collection)
                Add(item);
        }

        #endregion Adding elements

        #region Removing elements

        /// <summary>
        /// Searches the bag for one item equal to <paramref name="item"/>, and if found,
        /// removes it from the bag. If not found, the bag is unchanged. 
        /// </summary>
        /// <remarks>
        /// <para>Equality between items is determined by the comparison instance or delegate used
        /// to create the bag.</para>
        /// <para>Removing an item from the bag takes approximated constant time,
        /// regardless of the number of items in the bag.</para></remarks>
        /// <param name="item">The item to remove.</param>
        /// <returns>True if <paramref name="item"/> was found and removed. False if <paramref name="item"/> was not in the bag.</returns>
        public sealed override bool Remove(T item)
        {
            KeyValuePair<T, int> removed, newPair;
            if (hash.Delete(NewPair(item), out removed)) {
                if (removed.Value > 1) {
                    // Only want to remove one copied, so add back in with a reduced count.
                    KeyValuePair<T, int> dummy;
                    newPair = NewPair(removed.Key, removed.Value - 1);
                    hash.Insert(newPair, true, out dummy);
                }
                --count;
                return true;
            }
            else
                return false;
        }

        /// <summary>
        /// Searches the bag for all items equal to <paramref name="item"/>, and 
        /// removes all of them from the bag. If not found, the bag is unchanged.
        /// </summary>
        /// <remarks>
        /// <para>Equality between items is determined by the comparer instance used
        /// to create the bag.</para>
        /// <para>RemoveAllCopies() takes time O(M log N), where N is the total number of items in the bag, and M is
        /// the number of items equal to <paramref name="item"/>.</para></remarks>
        /// <param name="item">The item to remove.</param>
        /// <returns>The number of copies of <paramref name="item"/> that were found and removed. </returns>
        public int RemoveAllCopies(T item)
        {
            KeyValuePair<T, int> removed;
            if (hash.Delete(NewPair(item), out removed)) {
                count -= removed.Value;
                return removed.Value;
            }
            else
                return 0;
        }

        /// <summary>
        /// Removes all the items in <paramref name="collection"/> from the bag. Items that
        /// are not present in the bag are ignored.
        /// </summary>
        /// <remarks>
        /// <para>Equality between items is determined by the comparer instance used
        /// to create the bag.</para>
        /// <para>Removing the collection takes time O(M), where M is the 
        /// number of items in <paramref name="collection"/>.</para></remarks>
        /// <param name="collection">A collection of items to remove from the bag.</param>
        /// <returns>The number of items removed from the bag.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
        public int RemoveMany(IEnumerable<T> collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");

            int count = 0;

            if (collection == this) {
                count = Count;
                Clear();            // special case, otherwise we will throw.
            }
            else {
                foreach (T item in collection) {
                    if (Remove(item))
                        ++count;
                }
            }

            return count;
        }

        /// <summary>
        /// Removes all items from the bag.
        /// </summary>
        /// <remarks>Clearing the bag takes a constant amount of time, regardless of the number of items in it.</remarks>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产三级国产三级人妇 | 日本一区二区动态图| 精品处破学生在线二十三| 国产色一区二区| 亚洲日本在线视频观看| 午夜亚洲福利老司机| 国内精品国产成人| 日本道在线观看一区二区| 正在播放一区二区| 中文字幕av在线一区二区三区| 亚洲精品免费在线| 蜜桃久久久久久久| 91亚洲国产成人精品一区二区三 | 五月天激情综合| 国产美女在线精品| 色欧美片视频在线观看在线视频| 欧美一区二区三区日韩视频| 国产精品伦理一区二区| 午夜视频在线观看一区二区| 色婷婷一区二区| 成人免费精品视频| 9191国产精品| 一色屋精品亚洲香蕉网站| 欧美zozozo| 亚洲第一电影网| 岛国一区二区在线观看| 日韩一级视频免费观看在线| 中文字幕一区二区在线播放 | 欧美精品一区二区三区蜜臀| 亚洲欧美国产77777| 九九精品一区二区| 欧美精品乱人伦久久久久久| 国产蜜臀97一区二区三区| 人妖欧美一区二区| 日本韩国一区二区| 国产欧美日韩精品在线| 国产乱码精品一区二区三区av | 水蜜桃久久夜色精品一区的特点| 成人精品免费看| 欧美mv和日韩mv的网站| 亚洲自拍与偷拍| 99久久综合精品| 久久美女艺术照精彩视频福利播放| 亚洲成在人线在线播放| 99久久综合精品| 国产清纯在线一区二区www| 日韩国产欧美一区二区三区| 色欧美片视频在线观看| 综合久久一区二区三区| 国产成人aaaa| 久久久久久综合| 精品亚洲国产成人av制服丝袜| 欧美色手机在线观看| 亚洲男人的天堂一区二区| 成人做爰69片免费看网站| 337p日本欧洲亚洲大胆色噜噜| 亚洲va天堂va国产va久| 欧洲一区在线观看| 亚洲激情一二三区| 97精品国产97久久久久久久久久久久| 久久久美女艺术照精彩视频福利播放| 秋霞影院一区二区| 69成人精品免费视频| 欧美一区二区三区电影| 亚洲va韩国va欧美va精品| 欧洲一区在线电影| 亚洲成av人片一区二区| 欧美精品1区2区| 天涯成人国产亚洲精品一区av| 欧洲色大大久久| 亚洲国产日韩一区二区| 国产精品毛片大码女人| 综合激情成人伊人| 91免费版pro下载短视频| 1区2区3区国产精品| 99精品国产99久久久久久白柏| 国产精品国产三级国产三级人妇| 7777精品伊人久久久大香线蕉经典版下载| 亚洲精品高清在线| 欧美性受xxxx黑人xyx| 性做久久久久久免费观看| 欧美猛男gaygay网站| 日韩成人一级大片| 精品av久久707| 高清在线观看日韩| 亚洲视频在线观看三级| 色婷婷国产精品综合在线观看| 亚洲精品欧美综合四区| 精品视频免费在线| 美女在线观看视频一区二区| 久久一区二区三区四区| 国产成人在线看| 日韩美女精品在线| 欧美色手机在线观看| 久久精品国产**网站演员| 久久精品日韩一区二区三区| 久久人人超碰精品| 成人精品视频.| 亚洲v中文字幕| 精品国产免费人成在线观看| 成人午夜又粗又硬又大| 一区二区高清在线| 91精品国产欧美日韩| 国产精品91xxx| 亚洲欧美日韩精品久久久久| 欧美日韩一区二区在线观看| 久久精品在这里| 色丁香久综合在线久综合在线观看| 亚洲高清久久久| 久久女同精品一区二区| 91麻豆精东视频| 性久久久久久久久久久久 | 国产美女娇喘av呻吟久久| 国产精品久久久久桃色tv| 欧美影片第一页| 寂寞少妇一区二区三区| 国产精品久久久久影院| 欧美日本一道本在线视频| 国产乱子轮精品视频| 亚洲欧美日韩中文字幕一区二区三区| 亚洲欧美一区二区久久| 91麻豆免费看片| 蜜桃视频在线观看一区二区| 中文字幕永久在线不卡| 欧美一区二区三区影视| av午夜精品一区二区三区| 日本成人在线看| 日韩伦理免费电影| 精品国产一区a| 欧美午夜寂寞影院| 成人在线综合网| 青娱乐精品在线视频| 国产传媒一区在线| 欧美大片一区二区三区| 一本色道综合亚洲| 国产成人在线看| 久久精品久久精品| 亚洲制服欧美中文字幕中文字幕| 欧美精品一区二区久久婷婷| 欧美性猛交xxxxxxxx| 国产v日产∨综合v精品视频| 青青草国产精品97视觉盛宴 | 欧洲一区二区三区免费视频| 国产高清久久久| 日本欧美韩国一区三区| 亚洲精品一卡二卡| 国产欧美一区二区三区网站| 91麻豆精品国产无毒不卡在线观看| av电影天堂一区二区在线观看| 奇米在线7777在线精品| 亚洲一区二区三区自拍| 9l国产精品久久久久麻豆| 国产一区二区三区精品视频| 亚洲成av人片在www色猫咪| 亚洲日本韩国一区| 国产精品三级视频| 久久精品一区二区三区四区| 日韩一区二区三区在线视频| 在线精品视频一区二区三四| aa级大片欧美| 懂色av一区二区三区免费看| 精品一区二区三区在线视频| 舔着乳尖日韩一区| 午夜久久电影网| 亚洲自拍偷拍欧美| 亚洲一卡二卡三卡四卡无卡久久| 国产精品理论片在线观看| 国产婷婷色一区二区三区 | 99久久久无码国产精品| 国产精品主播直播| 韩国精品主播一区二区在线观看 | 久久久久国产成人精品亚洲午夜| 日韩三级精品电影久久久| 欧美高清视频不卡网| 欧美色手机在线观看| 欧美曰成人黄网| 欧美天堂亚洲电影院在线播放| 色香蕉久久蜜桃| 91久久一区二区| 欧美综合一区二区三区| 在线精品观看国产| 在线观看一区二区视频| 在线精品视频一区二区| 欧美日韩高清影院| 欧美高清视频不卡网| 日韩三级av在线播放| 日韩欧美美女一区二区三区| 精品国产不卡一区二区三区| 26uuu色噜噜精品一区二区| 久久无码av三级| 国产欧美日韩在线视频| 国产精品视频一二三| 中文字幕一区二区在线播放| 一区二区在线观看视频在线观看| 亚洲欧美国产毛片在线| 性欧美疯狂xxxxbbbb| 麻豆精品新av中文字幕| 国产在线麻豆精品观看| 粉嫩av一区二区三区| 色婷婷综合久久久|