自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-12-28 7f2edc4bf3b3d2ac429abb9a06ac7f425b2a01fd
#
1个文件已修改
27 ■■■■ 已修改文件
src/main/java/com/zy/core/News.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/News.java
@@ -39,19 +39,25 @@
        public NewsQueue(Class<T> cls, int capacity) {
            this.cls = cls;
            arr = (T[]) Array.newInstance(cls, capacity);
            this.arr = (T[]) Array.newInstance(cls, capacity);
            this.capacity = capacity;
        }
        public synchronized boolean offer(T t) {
            if (this.tail == this.capacity) {
                this.peek();
            }
            this.reform();
            this.arr[this.tail] = t;
            this.tail ++;
            return true;
        }
        public synchronized boolean put(T t) {
            if (this.tail == this.capacity) {
                return false;
            } else {
                for (int i = this.head; i < this.tail; i++) {
                    this.arr[i-this.head] = this.arr[i];
                }
                this.tail -= this.head;
                this.head = 0;
                this.reform();
            }
            this.arr[this.tail] = t;
            this.tail ++;
@@ -64,9 +70,18 @@
            }
            T t = this.arr[this.head];
            this.head ++;
            this.reform();
            return t;
        }
        private void reform() {
            for (int i = this.head; i < this.tail; i++) {
                this.arr[i-this.head] = this.arr[i];
            }
            this.tail -= this.head;
            this.head = 0;
        }
        public synchronized int size() {
            return this.tail - this.head;
        }