By Daniel · December 29, 2008
Returns a string representation of the given priority queue
// ds_priority_repr(id, ascending)
// Returns a string representation of the given priority queue
var copy, s, e;
copy = ds_priority_create();
ds_priority_copy(copy, argument0);
s = '';
while (!ds_priority_empty(copy)) {
if (s != '')
s += ', ';
if (argument1)
e = ds_priority_find_min(copy);
else
e = ds_priority_find_max(copy);
s += string(e) + ' (' + string(ds_priority_find_priority(copy, e)) + ')';
ds_priority_delete_value(copy, e);
}
s = '[' + s + ']';
return s;
Categories: Data processing, String handling
There are no comments to display.
You must be signed in to post comments.