code: public static <V> int sum(final List<V> values, final ToIntFunction<V> function)
      {
          int total = 0;
  
          final int size = values.size();
          for (int i = 0; i < size; i++)
          {
              final V value = values.get(i);
              total += function.applyAsInt(value);
          }
  
          return total;
      }
docs: Garbage free sum function.
  <p>
  <b>Note:</b> the list must implement {@link java.util.RandomAccess} to be efficient.
  
  @param values   the list of input values
  @param function function that map each value to an int
  @param <V>      the value to add up
  @return the sum of all the int values returned for each member of the list.