code: @Override
    /*! #if ($TemplateOptions.KTypePrimitive) 
    public KType [] toArray() {
        #else !*/
    public Object[] toArray() {
    /*! #end !*/
      final KType[] cloned = Intrinsics.<KType> newArray(size());
      int j = 0;
      if (hasEmptyKey) {
        cloned[j++] = Intrinsics.empty();
      }
  
      final KType[] keys = Intrinsics.<KType[]> cast(this.keys);
      for (int slot = 0, max = mask; slot <= max; slot++) {
        KType existing;
        if (!Intrinsics.isEmpty(existing = keys[slot])) {
          cloned[j++] = existing;
        }
      }
  
      return cloned;
    }
docs: {@inheritDoc}