docs: @Override
      @SuppressWarnings("unchecked")
      public <T> T[] toArray(T a[]) {
          Object[] elements = getArray();
          int len = elements.length;
          if (a.length < len)
              return (T[]) Arrays.copyOf(elements, len, a.getClass());
          else {
              System.arraycopy(elements, 0, a, 0, len);
              if (a.length > len)
                  a[len] = null;
              return a;
          }
      }