class HugeLongArray extends HugeArray<long[], Long, HugeLongArray> {

    public static long memoryEstimation(long size) {
        assert size >= 0;

        if (size <= ArrayUtil.MAX_ARRAY_LENGTH) {
            return sizeOfInstance(SingleHugeLongArray.class) + sizeOfLongArray((int)size);
        }
        long sizeOfInstance = sizeOfInstance(PagedHugeLongArray.class);

        int numPages = numberOfPages(size);

        long memoryUsed = sizeOfObjectArray(numPages);
        final long pageBytes = sizeOfLongArray(PAGE_SIZE);
        memoryUsed += (numPages - 1) * pageBytes;
        final int lastPageSize = exclusiveIndexOfPage(size);

        return sizeOfInstance + memoryUsed + sizeOfLongArray(lastPageSize);
    }

}