Java代码:

public class MyQueue {

    private Object[] queue; // 队列数组
    private int front; // 队头指针
    private int rear; // 队尾指针
    private int size; // 队列元素个数

    public MyQueue() {
        this.queue = new Object[8]; // 默认容量为8
        this.front = 0;
        this.rear = -1;
        this.size = 0;
    }

    // 其他方法
}
一个构造方法以默认容量8俩创建一个队列

原文地址: https://www.cveoy.top/t/topic/bjmc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录