code: @Override
    public int[] toArray(int[] a)
    {
      if (a.length < size) {
        throw new IllegalArgumentException();
      }
      if (isEmpty()) {
        return a;
      }
      int i = 0;
      for (int element : this.cells) {
        if (element < 0)
        // removed or empty
        {
          continue;
        }
  
        // copy the element
        a[i++] = element;
      }
      Arrays.sort(a, 0, size);
      return a;
    }
docs: {@inheritDoc}