Java List Sum checkSum(List stringList)

Here you can find the source of checkSum(List stringList)

Description

check Sum

License

Apache License

Declaration

private static long checkSum(List<String> stringList) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class Main {
    private static final long PRIME = 31;

    private static long checkSum(List<String> stringList) {
        long result = 1;
        for (String string : stringList) {
            result = (result * PRIME) + checkSum(string);
        }/*from   w  w  w .  ja va 2 s .  c o m*/
        return result;
    }

    public static long checkSum(Map<String, List<String>> stringMap) {
        long result = 1;
        for (Entry<String, List<String>> entry : stringMap.entrySet()) {
            result = (result * PRIME) + checkSum(entry.getKey());
            result = (result * PRIME) + checkSum(entry.getValue());
        }
        return result;
    }

    public static long checkSum(String[] stringArray) {
        long result = 1;
        for (String string : stringArray) {
            result = (result * PRIME) + checkSum(string);
        }
        return result;
    }

    public static long checkSum(String string) {
        return (long) string.hashCode();
    }
}

Related

  1. addByteToMessage(final List message, final byte bytevalue, final int checksum)
  2. adjustSumOfSquareValue(List oper, Number adjustedOper1)
  3. calculateSum(List valueList)
  4. getListSum(List list)
  5. getResidualSumOfSquares(List response, List samples, int ta)
  6. getSum(final List values)
  7. getSum(List numList)