// Resize the sorted list to the new capacity.
 private void changeSortedListCapacity(int newCapacity) {
   assert mapType == MapType.SORTED_LIST;
   assert newCapacity >= num;
   String[] oldKeys = keys;
   double[] oldValues = values;
   allocate(newCapacity);
   System.arraycopy(oldKeys, 0, keys, 0, num);
   System.arraycopy(oldValues, 0, values, 0, num);
 }