Branch: Tag:

2015-08-13

2015-08-13 09:12:25 by Henrik Grubbström (Grubba) <grubba@grubba.org>

ADT.Heap: Added remove().

127:       return values[0];   } +  + //! Remove a value from the heap. + //! + //! @param value + //! Value to remove. + //! + //! @seealso + //! @[push()], @[pop()] + void remove(mixed value) + { +  int pos = search(values, value); +  if ((pos < 0) || (pos >= num_values)) return; +  +  values[pos] = values[--num_values]; +  values[num_values] = 0; +  if (pos < num_values) { +  if (!adjust_up(pos)) +  adjust_down(pos); +  } +  verify_heap(); + }