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


C# Queue.isEmpty方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            Queue<int> list = new Queue<int>();
            Console.WriteLine(list.isEmpty());
            list.enqueue(0);
            list.enqueue(5);
            list.enqueue(7);
            list.enqueue(-4);
            list.enqueue(0);

            Console.WriteLine(list.dequeue());
            Console.WriteLine(list.dequeue());
            Console.WriteLine(list.dequeue());
            list.enqueue(9);
            Console.WriteLine(list.dequeue());
            Console.WriteLine(list.isEmpty());
            Console.WriteLine(list.isEmpty());
            list.nuke();
            Console.WriteLine(list.isEmpty());
            Console.ReadKey();
        }
开发者ID:Jobair96,项目名称:ADTs-Algorithms,代码行数:21,代码来源:Program.cs

示例2: Main

    // try out the ADT Queue using static allocation
    public static void Main()
    {
        Queue q = new Queue();

           Console.Write("Inserting ints from 9 to 1 into queue gives:\n");
           for (int i = 9; i > 0; --i) {
          q.enQueue( i);
           }

           q.display();

           if (!q.isEmpty())
           {
           Console.Write("Deleting value {0} from front of queue", q.deQueue());
           }

           Console.Write("\nAdding value {0} to back of queue", 27);
           q.enQueue(27);
           q.display();
    }
开发者ID:C12331591,项目名称:College-Work,代码行数:21,代码来源:Queue.cs

示例3: TestMethodisEmpty

        public void TestMethodisEmpty() {

            Queue<String> queue = new Queue<String>();

            Assert.IsFalse(queue.isEmpty());
        }
开发者ID:Jobair96,项目名称:ADTs-Algorithms,代码行数:6,代码来源:QueueClassTest.cs

示例4: Bfs

        // Method for breadth-first traversal.
        // mode = 1 - normal traversal.
        // mode = 2 - vertex colouring.
        //
        public void Bfs(int start, int mode = 1)
        {
            // Initialize the queue for the traversal.
            //

            Queue<int> q = new Queue<int>();
            InitializeSearch();

            // Insert a first vertex in the queue.
            //

            q.Enqueue(start);
            discovered[start] = true;

            // In loop, while queue is not empty.
            //

            while (!q.isEmpty())
            {
                // Take a next vertex out the queue.
                //

                var v = q.Dequeue();

                // Make an action before traversal.
                //

                ProcessVertexEarly(v, mode);

                // Start traversal in the neighborhoods.
                //

                var p = edges[v];

                // In loop, while adjacency list is not null.
                //

                while (p != null)
                {
                    // Take the next adjacent vertex.
                    //

                    var y = p.y;

                    // If it is not processed or the graph is directed, then is it new edge.
                    //

                    if (processed[y] == false || directed == true)
                    {
                        ProcessEdge(v, y, mode);
                    }

                    // If it is not opened, add in the queue.
                    //

                    if (discovered[y] == false)
                    {
                        q.Enqueue(y);

                        // Mark vertex as open.
                        //

                        discovered[y] = true;

                        // Add parent vertex into the relationship array.
                        //

                        parent[y] = v;
                    }

                    // Go to next vertex.
                    //

                    p = p.next;
                }

                // Mark the current vertex as processed.
                //

                processed[v] = true;

                // Make an action after traversal.
                //

                ProcessVertexLate(v, mode);
            }

            isBfs = true;
        }
开发者ID:BobsAnton,项目名称:McDowell,代码行数:93,代码来源:Graph.cs

示例5: BF

    public void BF(int s)
    {
        id = 0;
        visited = new int[V + 1];

        int v, u;
        Node t;

        for (v = 1; v <= V; v++)
            visited[v] = 0;

        Queue q = new Queue();
        q.enQueue(s);

        while (!q.isEmpty())
        {
            v = q.deQueue();
            if (visited[v] == 0)
            {
                visited[v] = ++id;
                Console.WriteLine("Visiting Node {0} ", toChar(v));
                for (t = adj[v]; t != t.next; t = t.next)
                {
                    u = t.vert;
                    if (visited[u] == 0)
                        q.enQueue(u);
                }
            }
        }
    }
开发者ID:BDLazar,项目名称:Algorithms,代码行数:30,代码来源:IterativeBreathFirstSearch.cs


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