当前位置: 首页>>代码示例>>C#>>正文


C# Deque类代码示例

本文整理汇总了C#中Deque的典型用法代码示例。如果您正苦于以下问题:C# Deque类的具体用法?C# Deque怎么用?C# Deque使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Deque类属于命名空间,在下文中一共展示了Deque类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UndoBuffer

 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="UndoBuffer"/> class.
 /// </summary>
 public UndoBuffer()
 {
     InternalUndoStack = new Deque<IUndoableOperation>();
       InternalRedoStack = new Deque<IUndoableOperation>();
       UndoStack = new ReadOnlyCollection<IUndoableOperation>(InternalUndoStack);
       RedoStack = new ReadOnlyCollection<IUndoableOperation>(InternalRedoStack);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:11,代码来源:UndoBuffer.cs

示例2: TestRemoveAndTrim

        public void TestRemoveAndTrim()
        {
            var d = new Deque<int>(4);
            Assert.IsTrue(d.Count == 0);
            Assert.IsTrue(d.Capacity == 4);

            d.AddLast(0);
            d.AddLast(1);
            d.AddLast(2);
            d.AddLast(3);
            d.AddLast(4);
            d.AddLast(5);
            Assert.IsTrue(d.Count == 6);
            Assert.IsTrue(d.Capacity == 8);

            d.RemoveLast();
            d.RemoveLast();
            d.RemoveLast();
            Assert.IsTrue(d.Count == 3);
            Assert.IsTrue(d.Capacity == 8);

            d.TrimExcess();
            Assert.IsTrue(d.Count == 3);
            Assert.IsTrue(d.Capacity == 3);

            var arr = d.ToArray();
            var exp = new int[] { 0, 1, 2 };
            Assert.IsTrue(arr.Length == exp.Length);
            for (int i = 0; i < arr.Length; i++) {
                Assert.IsTrue(arr[i] == exp[i]);
            }
        }
开发者ID:rzubek,项目名称:UnityGameTools,代码行数:32,代码来源:DequeTest.cs

示例3: ContainsPUT

        public void ContainsPUT([PexAssumeUnderTest]IList<int> values, int val)
        {
            PexAssume.IsTrue(values.Contains(val));
            Deque<int> actual = new Deque<int> (values);

            Assert.AreEqual(true, actual.Contains(val));
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:7,代码来源:DequeTest.cs

示例4: Main

        static void Main()
        {
            Deque<int> deque = new Deque<int>();
            Deque<object> dequeOfObjects = new Deque<object>();

            //dequeOfIntegers.AddFront(5);
            //dequeOfIntegers.AddBack(10);
            //int frontRemoved = dequeOfIntegers.RemoveFront();
            //int backRemoced = dequeOfIntegers.RemoveBack();

            //int frontPeek = dequeOfIntegers.PeekFront();
            //int backPeek = dequeOfIntegers.PeekBack();

            //int elements = dequeOfIntegers.Count;
            //int maxCapacity = dequeOfIntegers.Capacity;

            deque.AddFront(10);
            deque.AddFront(50);

            System.Console.WriteLine(deque.Count);
            deque[0] = 500;
            System.Console.WriteLine(deque[0]);

            Deque<int> anotherDeque = new Deque<int>();
            anotherDeque.AddFront(5);
            anotherDeque.AddFront(10);

            Deque<int> result = deque + anotherDeque;
        }
开发者ID:valkanov,项目名称:TelerikAcademy,代码行数:29,代码来源:Program.cs

示例5: Main

        internal static void Main()
        {
            Deque<int> deque = new Deque<int>();
            deque.PushFirst(3);
            deque.PushFirst(5);
            deque.PushFirst(7);
            deque.PushLast(10);
            deque.PushLast(13);
            //The order of elements in Deque is: 7, 5, 3, 10, 13

            //This will write on console first element without removing it from Deque -> 7
            Console.WriteLine("Peek first element: {0}", deque.PeekFirst());

            //This will write on console last element without removing it from Deque -> 13
            Console.WriteLine("Peek last element: {0}", deque.PeekLast());

            //This will write on console first element and remove it from Deque -> 7 again
            Console.WriteLine("Pop first element: {0}", deque.PopFirst());

            //This will write on console first element and remove it from Deque -> 5 again
            Console.WriteLine("Pop first element: {0}", deque.PopFirst());

            //This will write on console last element and remove it from Deque -> 13 again
            Console.WriteLine("Pop last element: {0}", deque.PopLast());

            //In the deque now you have only two elements -> 3 and 10
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:27,代码来源:int+deque.cs

示例6: TestAddAndGrow

        public void TestAddAndGrow()
        {
            var d = new Deque<int>(0);
            Assert.IsTrue(d.Count == 0);
            Assert.IsTrue(d.Capacity == 0);

            d.AddFirst(1);
            Assert.IsTrue(d.Count == 1);
            Assert.IsTrue(d.Capacity == 4);

            d.AddFirst(0);
            Assert.IsTrue(d.Count == 2);
            Assert.IsTrue(d.Capacity == 4);

            d.AddLast(2);
            d.AddLast(3);
            Assert.IsTrue(d.Count == 4);
            Assert.IsTrue(d.Capacity == 4);

            d.AddLast(4);
            Assert.IsTrue(d.Count == 5);
            Assert.IsTrue(d.Capacity == 8);

            var arr = d.ToArray();
            var exp = new int[] { 0, 1, 2, 3, 4 };
            Assert.IsTrue(arr.Length == exp.Length);
            for (int i = 0; i < arr.Length; i++) {
                Assert.IsTrue(arr[i] == exp[i]);
            }
        }
开发者ID:rzubek,项目名称:UnityGameTools,代码行数:30,代码来源:DequeTest.cs

示例7: ClearPUT

        public void ClearPUT([PexAssumeUnderTest]int[] input)
        {
            Deque<int> actual = new Deque<int> (input);
            actual.Clear();

            PexAssert.AreEqual(0, actual.Count);
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:7,代码来源:DequeTest.cs

示例8: Should_return_isEmpty_after_ctor

 public void Should_return_isEmpty_after_ctor()
 {
     // arrange
     var deque = new Deque<string>();
     // act
     // assert
     Assert.IsTrue(deque.IsEmpty());
 }
开发者ID:syned,项目名称:Algoritms,代码行数:8,代码来源:DequeTests.cs

示例9: CopyConstructorPUT

        public void CopyConstructorPUT(int[] input)
        {
            Deque<int> actual = new Deque<int>(input);
            int[] output = new int[input.Length];
            actual.CopyTo(output, 0);

            CollectionAssert.AreEqual(input, output);
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:8,代码来源:DequeTest.cs

示例10: CopyConstructorTest

        public void CopyConstructorTest()
        {
            List<int> original = new List<int> { 12, 123, 1, 90 };
            Deque<int> actual = new Deque<int>(original);
            Deque<int> expected = new Deque<int> { 12, 123, 1, 90 };

            CollectionAssert.AreEqual(expected, actual);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:8,代码来源:DequeTest.cs

示例11: ConstructorExample

 public void ConstructorExample()
 {
     var deque = new Deque<string>();
     deque.EnqueueHead("cat");
     deque.EnqueueHead("dog");
     deque.EnqueueHead("canary");
     Assert.AreEqual(3, deque.Count);
 }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:8,代码来源:DequeExamples.cs

示例12: ClearTest

        public void ClearTest()
        {
            Deque<int> actual = new Deque<int> { 12, 45, 321 };

            actual.Clear();

            Assert.AreEqual(0, actual.Count);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:8,代码来源:DequeTest.cs

示例13: Simple

        public void Simple()
        {
            var deque = new Deque<int>();
            Assert.IsFalse(deque.IsReadOnly);

            deque = GetTestDeque();
            Assert.IsFalse(deque.IsReadOnly);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:8,代码来源:IsReadOnly.cs

示例14: DequeueBackCountNonEmptyDequeTest

        public void DequeueBackCountNonEmptyDequeTest()
        {
            Deque<int> actual = new Deque<int> { 10, 12, 13 };

            actual.DequeueBack();

            Assert.AreEqual(2, actual.Count);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:8,代码来源:DequeTest.cs

示例15: SetUp

 public void SetUp()
 {
     d = new Deque<int>();
     q = new Queue<int>();
     s = new Stack<int>();
     l = new List<int>();
     ll = new LinkedList<int>();
 }
开发者ID:telefunkenvf14,项目名称:Deque,代码行数:8,代码来源:DequeTests.cs


注:本文中的Deque类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。