Added a handy double split tool to ListUtils, may be useful to you in network splitting @unpairedbracket; takes in a double, divides it into a defined amount of segments, giving the top element the remains

This commit is contained in:
Aidan C. Brady 2013-12-16 11:16:10 -05:00
parent 646b22f5b5
commit a93d51a4a1

View file

@ -169,4 +169,21 @@ public class ListUtils
{
return (List<V>)Arrays.asList(values);
}
public static double[] splitNum(int size, double num)
{
double[] split = new double[size];
for(int i = 0; i < size; i++)
{
double remain = num%size;
double ret = (num-remain)/size;
ret += remain;
split[i] = ret;
num -= remain;
}
return split;
}
}