public <T> T[] toArrayHelper(T[] array, int offset) {
        final int n = colGetSize();
        if (array.length < n) {
            @SuppressWarnings("unchecked") T[] newArray
                    = (T[]) Array.newInstance(array.getClass().getComponentType(), n);
            array = newArray;
        }
        for (int i = 0; i < n; i++) {
            array[i] = (T) colGetEntry(i, offset);
        }
        if (array.length > n) {
            array[n] = null;
        }
        return array;
    }
Helper for writing standard Java collection interfaces to a data
structure like {@link ArrayMap}.

@author RePlugin Team
replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/utils/basic/MapCollections.java