Skip to content
Snippets Groups Projects
Commit a2ca3c27 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

ADT.Heap: Added _sprintf().

This should make it easier to find the cause for [bug 7644].
parent 91bd58b8
No related branches found
No related tags found
No related merge requests found
......@@ -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)";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment