List of utility methods to do Number Sum
int | sumHash(int hash, String element) sum Hash return hash * 31 + element.hashCode();
|
int | sumHash(int leftHash, int rightHash) Sums the hash of the left and the right children May be used only when calculating a non-leaf node's hash code from its children's hashes. return leftHash + rightHash;
|
int | sumIf(final Integer number, final Integer sum, final Boolean condition) sum If int result = number != null ? number : 0; if (Boolean.TRUE.equals(condition) && sum != null) { result += sum; return result; |
boolean | sumIsMod10(int sum) sum Is Mod return ((sum % 10) == 0);
|
int | sumLange(int _a, int _b) sum Lange int a = _a; int b = _b; if (_a > _b) { b = _a; a = _b; return (a + b) * (b - a + 1) / 2; |
double | sumLogProb(double a, double b) Returns Math.log(Math.exp(a) + Math.exp(b)). if (a == Double.NEGATIVE_INFINITY) { if (b == Double.NEGATIVE_INFINITY) return Double.NEGATIVE_INFINITY; return b; } else if (b == Double.NEGATIVE_INFINITY) return a; else if (a > b) return a + Math.log(1 + Math.exp(b - a)); ... |
String | summarize(String longString, int limit) summarize String s = longString; if (s.indexOf("<p>") > -1) s = s.substring(0, s.indexOf("<p>")); if (s.indexOf("\n") > -1) s = s.substring(0, s.indexOf("\n")); return s.length() > limit ? s.substring(0, limit) + "..." : s; |
String | summarizeCigarString(String cigarString) summarize Cigar String StringBuilder summarizedCigarString = new StringBuilder(); if (cigarString.length() > 0) { int numberOfRepeats = 1; char currentlyRepeatingChar = cigarString.charAt(0); for (int i = 1; i < cigarString.length(); i++) { char currentChar = cigarString.charAt(i); if (currentlyRepeatingChar == currentChar) { numberOfRepeats++; ... |
String | summary(String text) summary if (text == null) { return "null"; return text.substring(0, Math.min(10, text.length())); |
int | summatory(int value) Summatory. int summatoryValue = 0; for (int i = 0; i <= value; i++) summatoryValue += i; return summatoryValue; |