⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intqueue.java

📁 xstream是一个把java object序列化成xml文件的开源库,轻便好用
💻 JAVA
字号:
package com.thoughtworks.xstream.core.util;public final class IntQueue {    private final int[] data;    private int writePointer = 0;    private int readPointer = 0;    private boolean empty = true;    public IntQueue(int size) {        data = new int[size];    }    public void write(int value) {        if (!empty && writePointer == readPointer) {            throw new OverflowException();        }        data[writePointer++] = value;        if (writePointer == data.length) {            writePointer = 0;        }        empty = false;    }    public int read() {        if (empty) {            throw new NothingToReadException();        }        int result = data[readPointer++];        if (readPointer == data.length) {            readPointer = 0;        }        if (readPointer == writePointer) {            empty = true;        }        return result;    }    public boolean isEmpty() {        return empty;    }    public static class OverflowException extends RuntimeException {    }    public static class NothingToReadException extends RuntimeException {    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -