home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 January / Gamestar_69_2005-01_dvd.iso / Dema / theprojectv1-0.exe / FCData / Scripts.pak / Scripts / Map.lua < prev    next >
Encoding:
Text File  |  2004-07-21  |  675 b   |  31 lines

  1. Map = {
  2. }
  3.  
  4. ---------------------------------------------------------
  5. --
  6. function Map:Insert(key, value)
  7.     self[key] = value;
  8. end
  9.  
  10. ---------------------------------------------------------
  11. --
  12. function Map:Remove(key)
  13.     self[key] = nil;
  14. end
  15.  
  16. ---------------------------------------------------------
  17. --push a value at the end of the map and return the key
  18. function Map:Push(val)
  19.     local key=getn(self)+1;
  20.     self[key]=val;
  21.     return key;
  22. end
  23.  
  24. ---------------------------------------------------------
  25. --pop a value from the end of the map and return the val
  26. function Map:Pop()
  27.     local key=getn(self);
  28.     local val=self[key];
  29.     self[key]=nil;
  30.     return val;
  31. end