@SuppressWarnings("unchecked")
      public final <T> T[] toArray(T[] a) {
          long sz = map.mappingCount();
          if (sz > MAX_ARRAY_SIZE)
              throw new OutOfMemoryError(OOME_MSG);
          int m = (int)sz;
          T[] r = (a.length >= m) ? a :
              (T[])java.lang.reflect.Array
              .newInstance(a.getClass().getComponentType(), m);
          int n = r.length;
          int i = 0;
          for (E e : this) {
              if (i == n) {
                  if (n >= MAX_ARRAY_SIZE)
                      throw new OutOfMemoryError(OOME_MSG);
                  if (n >= MAX_ARRAY_SIZE - (MAX_ARRAY_SIZE >>> 1) - 1)
                      n = MAX_ARRAY_SIZE;
                  else
                      n += (n >>> 1) + 1;
                  r = Arrays.copyOf(r, n);
              }
              r[i++] = (T)e;
          }
          if (a == r && i < n) {
              r[i] = null; // null-terminate
              return r;
          }
          return (i == n) ? r : Arrays.copyOf(r, i);
      }
@SuppressWarnings("unchecked")
      public final <T> T[] toArray(T[] a)