home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / tinymud2.zip / UTILS.C < prev    next >
C/C++ Source or Header  |  1990-09-02  |  756b  |  47 lines

  1. #include "copyright.h"
  2.  
  3. #include "db.h"
  4.  
  5. /* remove the first occurence of what in list headed by first */
  6. dbref remove_first(dbref first, dbref what)
  7. {
  8.     dbref prev;
  9.  
  10.     /* special case if it's the first one */
  11.     if(first == what) {
  12.     return db[first].next;
  13.     } else {
  14.     /* have to find it */
  15.     DOLIST(prev, first) {
  16.         if(db[prev].next == what) {
  17.         db[prev].next = db[what].next;
  18.         return first;
  19.         }
  20.     }
  21.     return first;
  22.     }
  23. }
  24.  
  25. int member(dbref thing, dbref list)
  26. {
  27.     DOLIST(list, list) {
  28.     if(list == thing) return 1;
  29.     }
  30.  
  31.     return 0;
  32. }
  33.  
  34. dbref reverse(dbref list)
  35. {
  36.     dbref newlist;
  37.     dbref rest;
  38.  
  39.     newlist = NOTHING;
  40.     while(list != NOTHING) {
  41.     rest = db[list].next;
  42.     PUSH(list, newlist);
  43.     list = rest;
  44.     }
  45.     return newlist;
  46. }
  47.