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

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

?? deque.cs

?? C#寫的類似于STL的集合類,首先是C#編寫,可以用于.net變程.
?? CS
?? 第 1 頁 / 共 3 頁
字號:
?//******************************
// 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: always create a small initial buffer, so that the checks in Add for a null buffer aren't needed. This 
// would improve performance slightly, but make empty Deque's take more memory. 

namespace Wintellect.PowerCollections
{
    /// <summary>
    /// <para>The Deque class implements a type of list known as a Double Ended Queue. A Deque
    /// is quite similar to a List, in that items have indices (starting at 0), and the item at any
    /// index can be efficiently retrieved. The difference between a List and a Deque lies in the
    /// efficiency of inserting elements at the beginning. In a List, items can be efficiently added
    /// to the end, but inserting an item at the beginning of the List is slow, taking time 
    /// proportional to the size of the List. In a Deque, items can be added to the beginning 
    /// or end equally efficiently, regardless of the number of items in the Deque. As a trade-off
    /// for this increased flexibility, Deque is somewhat slower than List (but still constant time) when
    /// being indexed to get or retrieve elements. </para>
    /// </summary>
    /// <remarks>
    /// <para>The Deque class can also be used as a more flexible alternative to the Queue 
    /// and Stack classes. Deque is as efficient as Queue and Stack for adding or removing items, 
    /// but is more flexible: it allows access
    /// to all items in the queue, and allows adding or removing from either end.</para>
    /// <para>Deque is implemented as a ring buffer, which is grown as necessary. The size
    /// of the buffer is doubled whenever the existing capacity is too small to hold all the
    /// elements.</para>
    /// </remarks>
    /// <typeparam name="T">The type of items stored in the Deque.</typeparam>
    [Serializable]
    public class Deque<T> : ListBase<T>, ICloneable
    {
        // The initial size of the buffer.
        private const int INITIAL_SIZE = 8;

        // A ring buffer containing all the items in the deque. Shrinks or grows as needed.
        // Except temporarily during an add, there is always at least one empty item.
        private T[] buffer;

        // Index of the first item (index 0) in the deque.
        // Always in the range 0 through buffer.Length - 1.
        private int start;

        // Index just beyond the last item in the deque. If equal to start, the deque is empty.
        // Always in the range 0 through buffer.Length - 1.
        private int end;

        // Holds the change stamp for the collection.
        private int changeStamp;

        /// <summary>
        /// Must be called whenever there is a structural change in the tree. Causes
        /// changeStamp to be changed, which causes any in-progress enumerations
        /// to throw exceptions.
        /// </summary>
        private void StopEnumerations()
        {
            ++changeStamp;
        }

        /// <summary>
        /// Checks the given stamp against the current change stamp. If different, the
        /// collection has changed during enumeration and an InvalidOperationException
        /// must be thrown
        /// </summary>
        /// <param name="startStamp">changeStamp at the start of the enumeration.</param>
        private void CheckEnumerationStamp(int startStamp)
        {
            if (startStamp != changeStamp) {
                throw new InvalidOperationException(Strings.ChangeDuringEnumeration);
            }
        }

        /// <summary>
        /// Create a new Deque that is initially empty.
        /// </summary>
        public Deque()
        {
        }

        /// <summary>
        /// Create a new Deque initialized with the items from the passed collection,
        /// in order.
        /// </summary>
        /// <param name="collection">A collection of items to initialize the Deque with.</param>
        public Deque(IEnumerable<T> collection)
        {
            AddManyToBack(collection);
        }

        /// <summary>
        /// Gets the number of items currently stored in the Deque. The last item
        /// in the Deque has index Count-1.
        /// </summary>
        /// <remarks>Getting the count of items in the Deque takes a small constant
        /// amount of time.</remarks>
        /// <value>The number of items stored in this Deque.</value>
        public sealed override int Count
        {
            get {
                if (end >= start)
                    return end - start;
                else
                    return end + buffer.Length - start;
            }
        }

        /// <summary>
        /// Copies all the items in the Deque into an array.
        /// </summary>
        /// <param name="array">Array to copy to.</param>
        /// <param name="arrayIndex">Starting index in <paramref name="array"/> to copy to.</param>
        public sealed override void CopyTo(T[] array, int arrayIndex)
        {
            if (array == null)
                throw new ArgumentNullException("array");

            // This override is provided to give a more efficient implementation to CopyTo than
            // the default one provided by CollectionBase.

            int length = (buffer == null) ? 0 : buffer.Length;

            if (start > end) {
                Array.Copy(buffer, start, array, arrayIndex, length - start);
                Array.Copy(buffer, 0, array, arrayIndex + length - start, end);
            }
            else {
                if (end > start)
                    Array.Copy(buffer, start, array, arrayIndex, end - start);
            }
        }

        /// <summary>
        /// Gets or sets the capacity of the Deque. The Capacity is the number of
        /// items that this Deque can hold without expanding its internal buffer. Since
        /// Deque will automatically expand its buffer when necessary, in almost all cases
        /// it is unnecessary to worry about the capacity. However, if it is known that a
        /// Deque will contain exactly 1000 items eventually, it can slightly improve 
        /// efficiency to set the capacity to 1000 up front, so that the Deque does not
        /// have to expand automatically.
        /// </summary>
        /// <value>The number of items that this Deque can hold without expanding its
        /// internal buffer.</value>
        /// <exception cref="ArgumentOutOfRangeException">The capacity is being set
        /// to less than Count, or to too large a value.</exception>
        public int Capacity
        {
            get
            {
                if (buffer == null)
                    return 0;
                else
                    return buffer.Length - 1;
            }
            set
            {
                if (value < Count)
                    throw new ArgumentOutOfRangeException("value", Strings.CapacityLessThanCount);
                if (value > int.MaxValue - 1)
                    throw new ArgumentOutOfRangeException("value");
                if (value == Capacity)
                    return;

                T[] newBuffer = new T[value + 1];
                CopyTo(newBuffer, 0);
                end = Count;
                start = 0;
                buffer = newBuffer;
            }
        }

        /// <summary>
        /// Trims the amount of memory used by the Deque by changing
        /// the Capacity to be equal to Count. If no more items will be added
        /// to the Deque, calling TrimToSize will reduce the amount of memory
        /// used by the Deque.
        /// </summary>
        public void TrimToSize()
        {
            Capacity = Count;
        }

        /// <summary>
        /// Removes all items from the Deque.
        /// </summary>
        /// <remarks>Clearing the Deque takes a small constant amount of time, regardless of
        /// how many items are currently in the Deque.</remarks>
        public sealed override void Clear()
        {
            StopEnumerations();
            buffer = null;
            start = end = 0;
        }

        /// <summary>
        /// Gets or sets an item at a particular index in the Deque. 
        /// </summary>
        /// <remarks>Getting or setting the item at a particular index takes a small constant amount
        /// of time, no matter what index is used.</remarks>
        /// <param name="index">The index of the item to retrieve or change. The front item has index 0, and
        /// the back item has index Count-1.</param>
        /// <returns>The value at the indicated index.</returns>
        /// <exception cref="ArgumentOutOfRangeException">The index is less than zero or greater than or equal
        /// to Count.</exception>
        public sealed override T this[int index]
        {
            get
            {
                int i = index + start;
                if (i < start)  // handles both the case where index < 0, or the above addition overflow to a negative number.
                    throw new ArgumentOutOfRangeException("index");

                if (end >= start) {
                    if (i >= end)
                        throw new ArgumentOutOfRangeException("index");
                    return buffer[i];
                }
                else {
                    int length = buffer.Length;
                    if (i >= length) {
                        i -= length;
                        if (i >= end)
                            throw new ArgumentOutOfRangeException("index");
                    }
                    return buffer[i];
                }
            }

            set
            {
                // Like List<T>, we stop enumerations after a set operation. There is no
                // technical reason to do this, however.
                StopEnumerations();

                int i = index + start;
                if (i < start)  // handles both the case where index < 0, or the above addition overflow to a negative number.
                    throw new ArgumentOutOfRangeException("index");

                if (end >= start) {
                    if (i >= end)
                        throw new ArgumentOutOfRangeException("index");
                    buffer[i] = value;
                }
                else {
                    int length = buffer.Length;
                    if (i >= length) {
                        i -= length;
                        if (i >= end)
                            throw new ArgumentOutOfRangeException("index");
                    }
                    buffer[i] = value;
                }
            }
        }

        /// <summary>
        /// Enumerates all of the items in the list, in order. The item at index 0
        /// is enumerated first, then the item at index 1, and so on. If the items
        /// are added to or removed from the Deque during enumeration, the 
        /// enumeration ends with an InvalidOperationException.
        /// </summary>
        /// <returns>An IEnumerator&lt;T&gt; that enumerates all the
        /// items in the list.</returns>
        /// <exception cref="InvalidOperationException">The Deque has an item added or deleted during the enumeration.</exception>
        public sealed override IEnumerator<T> GetEnumerator()
        {
            int startStamp = changeStamp;
            int count = Count;

            for (int i = 0; i < count; ++i) {
                yield return this[i];
                CheckEnumerationStamp(startStamp);
            }
        }

        /// <summary>
        /// Creates the initial buffer and initialized the Deque to contain one initial
        /// item.
        /// </summary>
        /// <param name="firstItem">First and only item for the Deque.</param>
        private void CreateInitialBuffer(T firstItem)
        {
            // The buffer hasn't been created yet.
            buffer = new T[INITIAL_SIZE];
            start = 0;
            end = 1;
            buffer[0] = firstItem;
            return;
        }

        /// <summary>
        /// Inserts a new item at the given index in the Deque. All items at indexes 
        /// equal to or greater than <paramref name="index"/> move up one index
        /// in the Deque.
        /// </summary>
        /// <remarks>The amount of time to insert an item in the Deque is proportional
        /// to the distance of index from the closest end of the Deque: 
        /// O(Min(<paramref name="index"/>, Count - <paramref name="index"/>)).
        /// Thus, inserting an item at the front or end of the Deque is always fast; the middle of
        /// of the Deque is the slowest place to insert.
        /// </remarks>
        /// <param name="index">The index in the Deque to insert the item at. After the
        /// insertion, the inserted item is located at this index. The
        /// front item in the Deque has index 0.</param>
        /// <param name="item">The item to insert at the given index.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
        /// less than zero or greater than Count.</exception>
        public sealed override void Insert(int index, T item)
        {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美极品aⅴ影院| 午夜日韩在线观看| 婷婷成人综合网| 丁香婷婷深情五月亚洲| 91 com成人网| 亚洲激情五月婷婷| 成人福利视频网站| 久久久久久黄色| 日韩国产高清影视| 日本国产一区二区| 亚洲天堂成人在线观看| 成人午夜又粗又硬又大| 欧美大片日本大片免费观看| 亚洲妇女屁股眼交7| 在线亚洲人成电影网站色www| 久久一日本道色综合| 毛片av一区二区三区| 欧美亚洲自拍偷拍| 一区二区三区国产| 国产欧美日韩在线| 精品一区二区三区在线视频| 555www色欧美视频| 婷婷亚洲久悠悠色悠在线播放| 91伊人久久大香线蕉| 亚洲欧美自拍偷拍| 99久久综合色| 亚洲久草在线视频| 91国产福利在线| 亚洲一区二区三区小说| 一本久久精品一区二区| 综合中文字幕亚洲| 欧美在线观看视频在线| 亚洲一区二区精品视频| 欧美日韩免费在线视频| 午夜精品爽啪视频| 在线成人av网站| 美女一区二区三区在线观看| 精品国产区一区| 极品尤物av久久免费看| 中文字幕av一区二区三区高| 成人激情免费电影网址| 亚洲人成网站在线| 欧美在线色视频| 天堂久久一区二区三区| 日韩一区二区视频在线观看| 久久国产精品免费| 国产精品嫩草影院com| 色94色欧美sute亚洲线路一ni| 尤物av一区二区| 正在播放亚洲一区| 国产精品1区2区3区在线观看| 国产日韩欧美a| 欧美亚日韩国产aⅴ精品中极品| 亚洲风情在线资源站| 精品精品国产高清a毛片牛牛| 国产在线播放一区三区四| 国产精品网曝门| 91成人网在线| 激情五月婷婷综合| 亚洲视频一二区| 日韩一区二区电影| 成人网页在线观看| 日韩中文字幕麻豆| 欧美激情一区二区三区全黄| 欧美性色综合网| 久久99精品国产麻豆不卡| 国产精品美女久久久久久久| 欧美日韩成人综合天天影院| 国产激情偷乱视频一区二区三区| 亚洲男人的天堂在线观看| 日韩三级.com| 色婷婷综合久久| 国产精品12区| 丝袜美腿亚洲综合| 国产精品乱人伦一区二区| 337p亚洲精品色噜噜狠狠| 不卡一区二区三区四区| 青青草原综合久久大伊人精品| 亚洲国产精华液网站w| 日韩免费看的电影| 91首页免费视频| 国产一区二区三区四区五区美女| av一区二区三区在线| 日韩成人午夜精品| 亚洲自拍偷拍麻豆| 国产精品日日摸夜夜摸av| 日韩写真欧美这视频| 色综合视频一区二区三区高清| 国产麻豆日韩欧美久久| 日韩高清在线一区| 亚洲国产中文字幕| 日韩伦理av电影| 国产日产欧美一区二区视频| 日韩一区二区在线看| 欧洲日韩一区二区三区| jizz一区二区| 国产高清不卡一区二区| 麻豆传媒一区二区三区| 日韩国产一区二| 一区二区三区在线免费| 日韩一区中文字幕| 中文幕一区二区三区久久蜜桃| 制服丝袜亚洲色图| 4438x亚洲最大成人网| 欧美日本视频在线| 欧美日韩一区在线观看| 在线观看日韩电影| 日本韩国精品一区二区在线观看| www.久久久久久久久| 粉嫩在线一区二区三区视频| 国产乱码一区二区三区| 国产在线播放一区| 激情另类小说区图片区视频区| 欧美a一区二区| 另类欧美日韩国产在线| 久久爱另类一区二区小说| 久久国产精品99久久人人澡| 老司机精品视频线观看86| 久久激情五月婷婷| 国产麻豆精品95视频| 国产夫妻精品视频| 成人91在线观看| 欧美在线999| 欧美情侣在线播放| www精品美女久久久tv| 久久久综合激的五月天| 中文字幕av在线一区二区三区| 国产精品第五页| 亚洲一卡二卡三卡四卡无卡久久 | 亚洲成人动漫在线观看| 亚洲永久精品国产| 午夜精品一区在线观看| 麻豆国产欧美一区二区三区| 精品一区二区免费在线观看| 国产精品系列在线观看| 不卡视频在线观看| 欧美日韩国产一级片| 日韩精品在线网站| 国产精品国产三级国产aⅴ原创| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲一级电影视频| 国产在线一区二区综合免费视频| 国产一区二区不卡在线 | 国产精品视频你懂的| 亚洲人成电影网站色mp4| 亚洲成a人v欧美综合天堂| 久久99国产精品久久99| 成人国产在线观看| 欧美美女一区二区三区| 国产日韩欧美高清在线| 亚洲高清在线精品| 成人免费毛片高清视频| 欧美日本不卡视频| 久久精品一区二区| 婷婷亚洲久悠悠色悠在线播放| 国产精品中文字幕欧美| 欧美剧情电影在线观看完整版免费励志电影| 在线综合+亚洲+欧美中文字幕| 日本一二三四高清不卡| 视频一区二区三区中文字幕| 国产成人精品免费网站| 欧美日韩在线播放三区四区| 日本一区二区三区视频视频| 亚洲成在人线在线播放| 成人黄色在线网站| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 一区二区不卡在线播放 | 在线免费观看不卡av| 久久久91精品国产一区二区三区| 一级做a爱片久久| 成人性生交大片免费看在线播放| 欧美妇女性影城| 亚洲免费成人av| 成人午夜电影小说| 精品剧情在线观看| 天堂va蜜桃一区二区三区漫画版| 国产91精品精华液一区二区三区| 91麻豆精品国产综合久久久久久| 亚洲人成网站色在线观看| 成人午夜免费电影| 国产日产欧美精品一区二区三区| 青青草成人在线观看| 欧美日韩一区二区三区视频| 亚洲三级在线播放| 成人激情小说网站| 国产精品免费久久| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 激情欧美日韩一区二区| 欧美一区二区三区免费视频| 一区二区三区.www| 色综合天天综合网天天狠天天| 日本一区二区三区国色天香 | 国产精品欧美极品| 国产一区二区三区精品欧美日韩一区二区三区 | 在线观看免费一区| 亚洲男人的天堂一区二区| 91色乱码一区二区三区| 国产自产高清不卡| 精品国产不卡一区二区三区| 毛片av一区二区三区|