zoukankan      html  css  js  c++  java
  • 队列课下作业

    作业内容

    • 1 补充课上没有完成的作业
    • 2 参考15.3节,用自己完成的队列(链队,循环数组队列)实现模拟票务柜台排队功能
    • 3 用JDB或IDEA单步跟踪排队情况,画出队列变化图,包含自己的学号信息
    • 4 把代码推送到代码托管平台
    • 5 把完成过程写一篇博客:重点是单步跟踪过程和遇到的问题及解决过程

    LinkedQueue代码

          package ch15;
         /**
        * Created by 47963 on 2017/10/18.
         */
        public class LinkedQueue<T> {
         private int count;
        private LinearNode<T> front,rear;
    
       
        public LinkedQueue(){
            count =0;
            front = rear = null;
        }
    
        public void enqueue(T element) {
            LinearNode<T> node = new LinearNode<T>(element);
            if(count == 0){
                front = node;
            }else {
                rear.setNext(node);
            }
            rear = node;
            count++;
        }
    
    
        public T dequeue() throws EmptyCollectionException {
            T a= front.getElement();
            if(count == 0){
                System.out.println("The queue is null.");
                rear=front=null;
            }else {
                front = front.getNext();
            }
            count--;
            return a;
        }
    
    
        public T first() {
            T A = front.getElement();
            return A;
        }
    
    
        public boolean isEmpty() {
            boolean result=false;
            if (count==0){
                result=true;
            }return result;
        }
    
    
        public int size() {
            return count;
        }
    
        /* public String toString(){}*/
         }
    

    TicketCounter运行结果截图

    image

    TicketCounter Debug截图

    image
    image

    队列分析

    NhDOS.jpg

  • 相关阅读:
    gdal source code c++ make windows
    libjpeg安装和使用
    window 安装gdal和python
    gdal和python在windows上的安装
    将博客搬至CSDN
    ue4 Worldmachine 结合使用
    织梦学习
    前端 css html js javascript jquery
    jquery 表单验证插件
    gif动图生成
  • 原文地址:https://www.cnblogs.com/cs162315/p/7712479.html
Copyright © 2011-2022 走看看