From a2ca3c27bd80a165a508683e63a424f6db423c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Tue, 9 Feb 2016 14:00:58 +0100 Subject: [PATCH] ADT.Heap: Added _sprintf(). This should make it easier to find the cause for [bug 7644]. --- lib/modules/ADT.pmod/Heap.pike | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/modules/ADT.pmod/Heap.pike b/lib/modules/ADT.pmod/Heap.pike index 41c3d9331d..b3ae98d568 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)"; +} -- GitLab