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

📄 intlist.java

📁 java实现的可配置的工作流引擎,采用jsp+javabean实现
💻 JAVA
字号:
package com.hongsoft.res.util;

public class IntList {

    int [] elements;
    int capacity;
    int size;

    /**
     * Creates a new list of long values with a default capacity of 50.
     */
    public IntList() {
        this(50);
    }

    /**
     * Creates a new list of long values with a specified initial capacity.
     *
     * @param initialCapacity a capacity to initialize the list with.
     */
    public IntList(int initialCapacity) {
        size = 0;
        capacity = initialCapacity;
        elements = new int[capacity];
    }

    /**
     * Adds a new long value to the end of the list.
     */
    public void add(int value) {
        elements[size] = value;
        size++;
        if (size == capacity) {
            capacity = capacity * 2;
            int[] newElements = new int[capacity];
            for (int i=0; i<size; i++) {
                newElements[i] = elements[i];
            }
            elements = newElements;
        }
    }

    /**
     * Returns the long value at the specified index. If the index is not
     * valid, an IndexOutOfBoundException will be thrown.
     *
     * @param index the index of the value to return.
     * @return the value at the specified index.
     */
    public int get(int index) {
        if (index < 0 || index >= size) {
            throw new IndexOutOfBoundsException("Index " + index + " not valid.");
        }
        return elements[index];
    }

    /**
     * Returns the number of elements in the list.
     *
     * @return the number of elements in the list.
     */
    public int size() {
        return size;
    }

    /**
     * Returns a new array containing the list elements.
     *
     * @return an array of the list elements.
     */
    public int[] toArray() {
        int size = this.size;
        int[] newElements = new int[size];
        for (int i=0; i<size; i++) {
            newElements[i] = elements[i];
        }
        return newElements;
    }

    public String toString() {
        StringBuffer buf = new StringBuffer();
        for (int i=0; i<this.size; i++) {
            buf.append(elements[i]).append(" ");
        }
        return buf.toString();
    }
}

⌨️ 快捷键说明

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