Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-19-2009, 08:24 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
data structures

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 
enqueueobj)
{
  
this.data.addobj);
}

public function 
dequeue()
{
  
this.data.remove(this.data[0]);
}

public function 
pushobj)
{
  
enqueue(obj);
}

public function 
pop()
{
  
temp.ret front();
  
dequeue();
  return 
ret;

Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.