home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / edit / jade / src / lists.c < prev    next >
C/C++ Source or Header  |  1994-04-28  |  2KB  |  84 lines

  1. /* lists.c -- Clones of the Amiga's exec-list functions
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4.    This file is part of Jade.
  5.  
  6.    Jade is free software; you can redistribute it and/or modify it
  7.    under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    Jade is distributed in the hope that it will be useful, but
  12.    WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with Jade; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "jade.h"
  21. #include "jade_protos.h"
  22.  
  23. void
  24. NewList(struct List *list)
  25. {
  26.     list->lh_TailPred = (struct Node *)&list->lh_Head;
  27.     list->lh_Tail = NULL;
  28.     list->lh_Head = (struct Node *)&list->lh_Tail;
  29. }
  30.  
  31. void
  32. AddTail(struct List *list, struct Node *node)
  33. {
  34.     struct Node *tmp, *tmp2;
  35.     tmp = (struct Node *)&list->lh_Tail;
  36.     tmp2 = tmp->ln_Pred;
  37.     tmp->ln_Pred = node;
  38.     node->ln_Succ = tmp;
  39.     node->ln_Pred = tmp2;
  40.     tmp2->ln_Succ = node;
  41. }
  42.  
  43. void
  44. Insert(struct List *list, struct Node *node, struct Node *listNode)
  45. {
  46.     struct Node *tmp;
  47.     if(listNode)
  48.     {
  49.     if((tmp = listNode->ln_Succ))
  50.     {
  51.         node->ln_Succ = tmp;
  52.         node->ln_Pred = listNode;
  53.         tmp->ln_Pred = node;
  54.         listNode->ln_Succ = node;
  55.     }
  56.     else
  57.     {
  58.         node->ln_Succ = listNode;
  59.         tmp = listNode->ln_Pred;
  60.         node->ln_Pred = tmp;
  61.         listNode->ln_Pred = node;
  62.         tmp->ln_Succ = node;
  63.     }
  64.     }
  65.     else
  66.     {
  67.     tmp = list->lh_Head;
  68.     list->lh_Head = node;
  69.     node->ln_Succ = tmp;
  70.     node->ln_Pred = (struct Node *)list;
  71.     tmp->ln_Pred = node;
  72.     }
  73. }
  74.  
  75. void
  76. Remove(struct Node *node)
  77. {
  78.     struct Node *tmp;
  79.     tmp = node->ln_Succ;
  80.     node = node->ln_Pred;
  81.     node->ln_Succ = tmp;
  82.     tmp->ln_Pred = node;
  83. }
  84.