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

version» Context lines:

pike.git/lib/modules/ADT.pmod/Heap.pike:6:      //! Heap element.   class Element (mixed value)   {    int pos = -1;       constant is_adt_heap_element = 1;       protected int `<(mixed other) { return value < other; }    protected int `>(mixed other) { return value > other; } +  +  protected string _sprintf(int c) +  { +  if (c != 'O') return "ADT.Heap()->Element()"; +  return sprintf("ADT.Heap()->Element(%O)[%d]", value, pos);    } -  + }      #define SWAP(X,Y) do{ mixed tmp=values[X]; (values[X]=values[Y])->pos = X; (values[Y]=tmp)->pos = Y; }while(0)      protected array(Element) values=allocate(10);   protected int num_values;      #ifdef ADT_HEAP_DEBUG   void verify_heap()   {    for(int e=0; e<num_values; e++) {
pike.git/lib/modules/ADT.pmod/Heap.pike:213:    if (pos < num_values) {    if (!adjust_up(pos))    adjust_down(pos);    }       if(num_values * 3 + 10 < sizeof(values))    values=values[..num_values+10];       verify_heap();   } +  + protected string _sprintf(int c) + { +  if (c != 'O') return "ADT.Heap()"; +  int cnt = num_values; +  Element e = sizeof(values) && values[0]; +  if (cnt) { +  return sprintf("ADT.Heap(%d elements, top: %O)", cnt, e); +  } +  return "ADT.Heap(0 elements)"; + }