public double getMax() {
        if (total_size == 0) return Double.NaN;

        double max = Double.NEGATIVE_INFINITY;
        if (type == Integer.class) {
            for (int i = 0; i < total_size; i++) {
                if (max < ((int[])vals)[i]) max = ((int[])vals)[i];
            }

        } else {
            for (int i = 0; i < total_size; i++) {
                if (max < ((double[])vals)[i]) max = ((double[])vals)[i];
            }
        }
        return max;
    }