boredom struck and I couldn't really find anything involving queues and stacks on the wiki (ActionMap has a push and pop which confused me) so I wrote up a queue real quick.
the most practical use I can think of for this right now is a spar system, where players joining the line are pushed on the queue, and you use a pop to get who's next in line.
I'll add a stack and some other data structures potentially tomorrow when I'm not tired.
queue:
PHP Code:
public function onCreated()
{
this.data = {null};
}
public function empty()
{
if (front() == null)
return true;
return false;
}
public function front()
{
if(this.data[0] == null)
return null;
else
return this.data[0];
}
public function enqueue( obj)
{
this.data.add( obj);
}
public function dequeue()
{
this.data.remove(this.data[0]);
}
public function push( obj)
{
enqueue(obj);
}
public function pop()
{
temp.ret = front();
dequeue();
return ret;
}