@Override
    public int[] toArray(int[] arr) {
      int size = this.size;
      if (arr == null) {
        arr = new int[size];
      }
      else if (arr.length < size) {
        arr = Arrays.copyOf(arr, size);
      }
      int idx = 0;
      if (hasZeroKey) {
        arr[idx++] = 0;
      }
      for (int val : data) {
        if (val != 0) {
          arr[idx++] = val;
        }
      }
      assert idx == size;
      return arr;
    }
@Override
    public int[] toArray(int[] arr)