diff --git a/lib/modules/ADT.pmod/Heap.pike b/lib/modules/ADT.pmod/Heap.pike index 41c3d9331dd02ba92482ffdb53f2b7244e58fa47..b3ae98d56840cb67fb120447aa6c08af3c21ea4b 100644 --- a/lib/modules/ADT.pmod/Heap.pike +++ b/lib/modules/ADT.pmod/Heap.pike @@ -13,6 +13,12 @@ class Element (mixed value) 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) @@ -229,3 +235,14 @@ void remove(mixed value) 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)"; +}