Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

ds_priority_repr

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;

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement