pike.git / lib / modules / ADT.pmod / Heap.pike

version» Context lines:

pike.git/lib/modules/ADT.pmod/Heap.pike:92:    return 0;   }      //! Push an element onto the heap. The heap will automatically sort itself   //! so that the smallest value will be at the top.   //!   //! @returns   //! Returns an element handle, which can be used with   //! @[adjust()] and @[remove()].   //! + //! @note + //! If @[value] is a @[Heap.Element] and already present on the heap + //! this is equivalent to calling @[adjust()]. + //!   //! @seealso   //! @[pop()], @[remove()]   Element push(mixed value)   {    Element ret;    if (objectp(value) && value->is_adt_heap_element) {    ret = value; -  +  +  if (ret->pos >= 0) { +  // Element already on the Heap. +  // FIXME: Verify that the element is on *this* heap? +  return adjust(ret); +  }    } else {    ret = Element(value);    }    if(num_values >= sizeof(values))    values+=allocate(10+sizeof(values)/4);       (values[num_values] = ret)->pos = num_values++;    adjust_up(num_values-1);    verify_heap();    return ret;