private void swim(int index) {
    if (index <= 0 || index > size) {
      return;
    }
    int parent = index / 2;
    while (parent > 0 && less(parent, index)) {
      swap(index, parent);
      index = parent;
      parent = index / 2;
    }
  }