code: private static <T extends Number> double[] extractValues(
              Map<Integer, T> map, int size)  {
          double[] values = new double[size];
          for (Map.Entry<Integer, T> entry : map.entrySet()) {
              if (entry.getKey() > values.length)
                  throw new IllegalArgumentException(
                          "Array size is too small for values in the " +
                          "given map");
              values[entry.getKey()] = entry.getValue().doubleValue();
          }
          return values;
      }
docs: Extracts the values from the given map into an array form.  This is
  neccesary since {@code toArray} on a {@link IntegerMap} does not work
  with primitives and {@code Map} does not provide this functionality.
  Each key in the map corresponds to an index in the array being
  created and the value is the value in stored at the specified index.