home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / aplusplus-1.01-src.lha / GNU / src / amiga / APlusPlus-1.01 / libsource / List.cxx < prev    next >
C/C++ Source or Header  |  1994-05-04  |  3KB  |  121 lines

  1. /******************************************************************************
  2.  **
  3.  **    C++ Class Library for the Amiga© system software.
  4.  **
  5.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **    All Rights Reserved.
  7.  **
  8.  **    $Source: apphome:APlusPlus/RCS/libsource/List.cxx,v $
  9.  **    $Revision: 1.3 $
  10.  **    $Date: 1994/04/23 21:01:51 $
  11.  **    $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <APlusPlus/exec/List.h>
  17.  
  18.  
  19. volatile static char rcs_id[] = "$Id: List.cxx,v 1.3 1994/04/23 21:01:51 Armin_Vogt Exp Armin_Vogt $";
  20.  
  21.  
  22. void MinListC__Destruct(MinListC *list)
  23.    /* prevents a destructed list object from being used via still existing nodes.
  24.       The nodes within the list are being disconnected from the list.
  25.    */
  26. {
  27.    FOREACHSAFE(MinNodeC,list)
  28.    {
  29.       node->remove();
  30.    }
  31.    NEXTSAFE
  32. }
  33.  
  34. BOOL MinListC__Member(MinListC *list,MinNodeC *find)
  35. {
  36.    FOREACHOF(MinNodeC,list)
  37.       if (node == find) return TRUE;
  38.  
  39.    return FALSE;
  40. }
  41.  
  42. MinNodeC *MinListC__RemoveSafely(MinListC *list,MinNodeC *node)
  43. {
  44.    if(list->member(node))
  45.    {
  46.       node->remove();
  47.    }
  48.  
  49.    return node;
  50. }
  51.  
  52. MinListC *MinNodeC::findList(void)
  53.    /* check if the node is chained into a list, then run through the list to
  54.       the start nil node that is integrated into the MinList structure and
  55.       return the MinListC object of this structure.
  56.    */
  57. {
  58.    if (isLonelyNode()) return NULL;   // this node is not chained into a list
  59.  
  60.    MinNode *node,*pred;
  61.    node = (MinNode*)this;
  62.    while (NULL != (pred = node->mln_Pred))   node = pred;
  63.    return (MinListC*)(MinList*)node;
  64. }
  65.  
  66. BOOL MinListC::apply(void *any)
  67.    /* It is safe for a MinNodeC object in the list to delete itself during the apply loop.
  68.    */
  69. {
  70.    FOREACHSAFE(MinNodeC,this)
  71.    {
  72.       if (node->applyMinNodeC(any)==FALSE) return FALSE;
  73.    }
  74.    NEXTSAFE
  75.    return TRUE;   // all nodes have been applied to
  76. }
  77.  
  78. BOOL ListC::apply(void *any)
  79.    /* It is safe for a NodeC object in the list to delete itself during the apply loop.
  80.    */
  81. {
  82.    FOREACHSAFE(NodeC,this)
  83.    {
  84.       if (node->applyNodeC(any)==FALSE) return FALSE;
  85.    }
  86.    NEXTSAFE
  87.  
  88.    return TRUE;   // all nodes have been applied to
  89. }
  90.  
  91. BOOL MinNodeC::applyMinNodeC(void *any)
  92.    return FALSE; 
  93. } // your subclass should overwrite this
  94.  
  95. BOOL NodeC::applyNodeC(void *any) 
  96.    return FALSE; 
  97. } // your subclass should overwrite this
  98.  
  99. MinListC::~MinListC()
  100.    MinListC__Destruct(this);
  101. }
  102.  
  103. MinNodeC::~MinNodeC()
  104.     remove(); 
  105. }
  106.         
  107. ListC::~ListC() 
  108.    MinListC__Destruct((MinListC*)(MinList*)(List*)this); 
  109. }
  110.  
  111. NodeC::~NodeC() 
  112.     remove(); 
  113. }
  114.  
  115.