class FastIntegerList {

    private boolean[] table;
    private int capacity;
    private int size;
    private int index;

    FastIntegerList(int capacity) {
        table = new boolean[capacity];
        this.capacity = capacity;
        clear();
    }

    public void add(int c) {
        if (table[c] == false) {
            table[c] = true;
            size++;
        }
    }

    public void clear() {
        for (int i = 0; i < capacity; i++) {
            table[i] = false;
        }
        size = 0;
        index = -1;
    }

    @Override
    public FastIntegerList clone() {
        FastIntegerList clone = new FastIntegerList(capacity);

        table = table.clone();
        clone.size = size;
        clone.index = index;
        return clone;
    }

    public boolean contains(int c) {
        return table[c];
    }

    public boolean equals(FastIntegerList arg) {
        if (capacity != arg.capacity || size != arg.size) {
            return false;
        } else {
            for (int i = 0; i < capacity; i++) {
                if (table[i] != arg.table[i]) {
                    return false;
                }
            }
            return true;
        }
    }

    public int next() {
        if (size == 0) {
            return -1;
        } else {
            do {
                index = (index + 1) % capacity;
            } while (table[index] == false);
            return index;
        }
    }

    public void remove(int c) {
        if (table[c] == true) {
            table[c] = false;
            size--;
        }
    }

    public void resetIterator() {
        index = -1;
    }
}