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


C# Queue.Add方法代码示例

本文整理汇总了C#中Queue.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.Add方法的具体用法?C# Queue.Add怎么用?C# Queue.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Queue的用法示例。


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

示例1: Main

    static void Main()
    {
        //Vector v = new Vector();
        //Stack v = new Stack();
        //LinkedList v = new LinkedList();

        Queue v = new Queue();
        v.Print();

        v.Add(0);
        v.Add(1);
        v.Add(2);
        v.Print();

        v.Remove();
        v.Print();

        v.Remove();
        v.Print();

        Console.ReadKey();

        //v.RemoveFirst();
        //v.Print();

        //v.RemoveLast();
        //v.Print();

        //v.RemoveLast();
        //v.Add(123);
        //v.Print();

        //Console.ReadKey();
    }
开发者ID:iProcyonidae,项目名称:MVS,代码行数:34,代码来源:Program.cs

示例2: Clear

 public void Clear()
 {
     var queue = new Queue();
     queue.Add("filename", 0, 1);
     queue.Add("filename", 10, 1);
     queue.Clear();
     Assert.AreEqual(0, queue.Count);
     Assert.IsTrue(queue.CurrentItem.IsEmpty);
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:9,代码来源:QueueTests.cs

示例3: ServiceRequestsController

        public ServiceRequestsController()
        {
            // No session in WebApi without jumping through hoops
            //_serviceQueue = WebApiApplication["_serviceQueue"];

            _serviceQueue = new Queue<ServiceRequest>();
            _serviceQueue.Add(new ServiceRequest("222-222-2222", "Downtown 7-11"));
            _serviceQueue.Add(new ServiceRequest("555-222-5555", "Downtown Dry Cleaners"));
            _serviceQueue.Add(new ServiceRequest("888-222-8888", "Downtown Butcher Shop"));
            _serviceQueue.Add(new ServiceRequest("444-222-1111", "Downtown Bakery Shop"));

            //WebApiApplication["_serviceQueue"] = _serviceQueue;
        }
开发者ID:chidojoseph,项目名称:TaxiService,代码行数:13,代码来源:ServiceRequestsController.cs

示例4: Add

 public void Add()
 {
     var queue = new Queue();
     queue.Add("filename", 100, 1);
     Assert.AreEqual(0, queue.Count);
     Assert.IsTrue(queue.CurrentItem.Equals("filename", 100, 1));
     queue.Add("filename", 100, 1);
     Assert.AreEqual(0, queue.Count);
     Assert.IsTrue(queue.CurrentItem.Equals("filename", 100, 1));
     queue.Add("filename", 110, 1);
     Assert.AreEqual(1, queue.Count);
     Assert.IsTrue(queue.CurrentItem.Equals("filename", 110, 1));
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:13,代码来源:QueueTests.cs

示例5: Main

 public static void Main()
 {
     try {
       Queue q1 = new Queue();
       Queue q2 = new Queue(3);
       q2.Add(4);
       q2.Add(5);
       Console.WriteLine("The front is now {0}", q2.Head());
       q2.Add(6);
       Console.WriteLine
             ("Removing from q2 returns {0}", q2.Remove());
       Console.WriteLine("Queue 1 has size {0}", q1.size);
       Console.WriteLine("Queue 1 empty? {0}", q1.IsEmpty());
       q1.Remove();
       Console.WriteLine("Throws exception before we get here");
     }catch(Exception e) {
     Console.WriteLine(e);
     }
 }
开发者ID:JnS-Software-LLC,项目名称:CSC153,代码行数:19,代码来源:Queue.cs

示例6: Backward

 public void Backward()
 {
     var queue = new Queue();
     queue.Add("filename0", 0, 1);
     queue.Add("filename1", 0, 1);
     queue.Add("filename2", 0, 1);
     queue.Add("filename3", 0, 1);
     queue.Add("filename4", 0, 1);
     queue.Backward();
     Assert.IsTrue(queue.CurrentItem.Equals("filename3", 0, 1));
     queue.Backward();
     Assert.IsTrue(queue.CurrentItem.Equals("filename2", 0, 1));
     queue.Backward();
     Assert.IsTrue(queue.CurrentItem.Equals("filename1", 0, 1));
     queue.Backward();
     Assert.IsTrue(queue.CurrentItem.Equals("filename0", 0, 1));
     queue.Backward();
     queue.Backward();
     queue.Backward();
     Assert.IsTrue(queue.CurrentItem.Equals("filename0", 0, 1));
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:21,代码来源:QueueTests.cs

示例7: ShouldBeAbleToAddAJobFromCSharpWithEase

        public async Task ShouldBeAbleToAddAJobFromCSharpWithEase()
        {
            // Given
            // Transaction mock for adding the job to the wait list and sending a pubsub message
            var transactionMock = new Mock<ITransaction>();
            transactionMock
                .Setup(t => t.ListLeftPushAsync(It.IsAny<RedisKey>(), It.IsAny<RedisValue>(), It.IsAny<When>(), It.IsAny<CommandFlags>()))
                .Returns(Task.FromResult(1L));
            transactionMock
                .Setup(t => t.PublishAsync(It.IsAny<RedisChannel>(), It.IsAny<RedisValue>(), It.IsAny<CommandFlags>()))
                .Returns(Task.FromResult(1L));
            transactionMock
                .Setup(t => t.ExecuteAsync(It.IsAny<CommandFlags>()))
                .Returns(Task.FromResult(true));
           
            // Database mock so you can add a job
            var databaseMock = new Mock<IDatabase>();
            databaseMock
                .Setup(d => d.HashSetAsync(It.IsAny<RedisKey>(), It.IsAny<HashEntry[]>(), It.IsAny<CommandFlags>()))
                .Returns(Task.Run(() => { }));
            databaseMock
                .Setup(d => d.StringIncrementAsync(It.IsAny<RedisKey>(), 1L, It.IsAny<CommandFlags>()))
                .Returns(Task.FromResult(1L));
            databaseMock
                .Setup(d => d.CreateTransaction(null))
                .Returns(transactionMock.Object);

            // So oxen can verify the internal subscription was successful
            var subscriberMock = new Mock<ISubscriber>();
            subscriberMock
                .Setup(s => s.PublishAsync(It.IsAny<RedisChannel>(), It.IsAny<RedisValue>(), It.IsAny<CommandFlags>()))
                .Returns(Task.FromResult(1L));

            IOxenQueue<Message> queue = new Queue<Message>("test-queue", () => databaseMock.Object, () => subscriberMock.Object);

            // When
            var job = await queue.Add(new Message()
            {
                OtherThing = false,
                Thing = "yes"
            });

            // Then
            job.data.Thing.ShouldEqual("yes");
            job.data.OtherThing.ShouldBeFalse();
            job.jobId.ShouldEqual(1L);

            databaseMock.Verify(db => db.HashSetAsync(It.IsAny<RedisKey>(), It.IsAny<HashEntry[]>(), It.IsAny<CommandFlags>()), Times.Once);
            databaseMock.Verify(db => db.StringIncrementAsync(It.IsAny<RedisKey>(), 1L, It.IsAny<CommandFlags>()), Times.Once);

            transactionMock.Verify(t => t.ListLeftPushAsync(It.IsAny<RedisKey>(), It.IsAny<RedisValue>(), It.IsAny<When>(), It.IsAny<CommandFlags>()), Times.Once);
            transactionMock.Verify(t => t.PublishAsync(It.IsAny<RedisChannel>(), It.IsAny<RedisValue>(), It.IsAny<CommandFlags>()), Times.Once);
        }
开发者ID:transformersprimeabcxyz,项目名称:oxen-fsprojects,代码行数:53,代码来源:FaçadeTests.cs

示例8: Change_3

 public void Change_3()
 {
     const string filename = "filename";
     var queue = new Queue();
     queue.Add(filename, position: 0, line: 1);
     queue.Add(filename, position: 6, line: 2);
     queue.Add(filename, position: 8, line: 3);
     Assert.IsTrue(queue.CurrentItem.Equals(filename, position: 8, line: 3));
     queue.Change(filename, startPosition: 4, charsAdded: -4, linesAdded: -1);
     Assert.IsTrue(queue.CurrentItem.Equals(filename, position: 4, line: 2));
     queue.Backward();
     Assert.IsTrue(queue.CurrentItem.Equals(filename, position: 0, line: 1));
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:13,代码来源:QueueTests.cs

示例9: Change

 public void Change()
 {
     var queue = new Queue();
     const string filename0 = "filename0";
     queue.Add(filename0, position: 0, line: 1);
     queue.Add("filename1", 1, 1);
     queue.Add(filename0, position: 100, line: 2);
     queue.Add("filename3", 1, 1);
     queue.Add(filename0, position: 1000, line: 3);
     queue.Change(filename0, startPosition: 150, charsAdded: 1, linesAdded: 1);
     Assert.IsTrue(queue.CurrentItem.Equals(filename0, position: 1001, line: 4));
     queue.Change(filename0, 0, 10, 1);
     Assert.IsTrue(queue.CurrentItem.Equals(filename0, position: 1011, line: 5));
     queue.Backward();
     queue.Backward();//skip filename3
     Assert.IsTrue(queue.CurrentItem.Equals(filename0, position: 110, line: 3));
     queue.Backward();
     queue.Backward();//skip filename1
     Assert.IsTrue(queue.CurrentItem.Equals(filename0, position: 10, line: 2));
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:20,代码来源:QueueTests.cs

示例10: CanForward

 public void CanForward()
 {
     var queue = new Queue();
     Assert.IsFalse(queue.CanForward);
     queue.Add("filename0", 0, 1);
     queue.Add("filename1", 0, 1);
     Assert.IsFalse(queue.CanForward);
     queue.Backward();
     Assert.IsTrue(queue.CanForward);
     queue.Forward();
     Assert.IsFalse(queue.CanForward);
     queue.Backward();
     queue.Add("filename3", 0, 1);
     Assert.IsFalse(queue.CanForward);
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:15,代码来源:QueueTests.cs

示例11: GetBackwardItem

 public void GetBackwardItem()
 {
     var queue = new Queue();
     Assert.IsTrue(queue.GetBackwardItem().IsEmpty);
     queue.Add("filename0", 0, 1);
     queue.Add("filename1", 0, 1);
     Assert.IsTrue(queue.GetBackwardItem().Equals("filename0", 0, 1));
 }
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:8,代码来源:QueueTests.cs


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