@Override
    public Iterator<E> iterator() {
        return new Iterator<E>() {
            private int current;

            @Override
            public boolean hasNext() {
                return current < realCount;
            }

            @Override
            @SuppressWarnings("unchecked")
            public E next() {
                if (hasNext())
                    return (E) array[current++];
                else
                    return null;
            }

            @Override
            public void remove() {
                if (!hasNext())
                    return;

                array[current] = null;
                for (int i = current + 1; i < realCount; i++) {
                    array[i - 1] = array[i];
                    array[i] = null;
                }
                realCount--;
            }
        };
    }