docs: @Override
    public long[] toArray() {
      long cardinality = this.getLongCardinality();
      if (cardinality > Integer.MAX_VALUE) {
        throw new IllegalStateException("The cardinality does not fit in an array");
      }
  
      final long[] array = new long[(int) cardinality];
  
      int pos = 0;
      LongIterator it = getLongIterator();
  
      while (it.hasNext()) {
        array[pos++] = it.next();
      }
      return array;
    }