code: public E[] asArray(IntFunction<E[]> arrayFactory) {
          long size = count();
          if (size >= Nodes.MAX_ARRAY_SIZE)
              throw new IllegalArgumentException(Nodes.BAD_SIZE);
          E[] result = arrayFactory.apply((int) size);
          copyInto(result, 0);
          return result;
      }
docs: Create a new array using the specified array factory, and copy the
  elements into it.