array Sum Internal - Android java.lang

Android examples for java.lang:array calculation

Description

array Sum Internal

Demo Code


//package com.java2s;

public class Main {
    public static final void arraySumInternal(final int[] pValues) {
        final int valueCount = pValues.length;
        for (int i = 1; i < valueCount; i++) {
            pValues[i] = pValues[i - 1] + pValues[i];
        }/*from w  w  w  .j a  v a 2s . c om*/
    }

    public static final void arraySumInternal(final long[] pValues) {
        final int valueCount = pValues.length;
        for (int i = 1; i < valueCount; i++) {
            pValues[i] = pValues[i - 1] + pValues[i];
        }
    }

    public static final void arraySumInternal(final long[] pValues,
            final long pFactor) {
        pValues[0] = pValues[0] * pFactor;
        final int valueCount = pValues.length;
        for (int i = 1; i < valueCount; i++) {
            pValues[i] = pValues[i - 1] + pValues[i] * pFactor;
        }
    }
}

Related Tutorials