home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_6.ZIP / DOSSRC.ZIP / LISTBLK.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  1.2 KB  |  55 lines

  1. //    Zinc Interface Library - LISTBLK.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_gen.hpp"
  6.  
  7. UI_LIST_BLOCK::~UI_LIST_BLOCK()
  8. {
  9.     // Establish null lists so it doesn't free up an unknown block.
  10.     first = last = 0;
  11.     freeList.first = freeList.last = 0;
  12. }
  13.  
  14. UI_ELEMENT *UI_LIST_BLOCK::Add(UI_ELEMENT *element)
  15. {
  16.     UI_ELEMENT *newElement = freeList.first;
  17.  
  18.     // Add a new list element to the use list at specified location.
  19.     if (newElement)
  20.     {
  21.         freeList.Subtract(newElement);
  22.         UI_LIST::Add(element, newElement);
  23.     }
  24.  
  25.     // Return a pointer to the new element.
  26.     return (newElement);
  27. }
  28.  
  29. UI_ELEMENT *UI_LIST_BLOCK::Add()
  30. {
  31.     UI_ELEMENT *newElement = freeList.first;
  32.  
  33.     // Add a new list element to the use list according to compareFunction.
  34.     if (newElement)
  35.     {
  36.         freeList.Subtract(newElement);
  37.         UI_LIST::Add(newElement);
  38.     }
  39.  
  40.     // Return a pointer to the new element.
  41.     return (newElement);
  42. }
  43.  
  44. UI_ELEMENT *UI_LIST_BLOCK::Subtract(UI_ELEMENT *element)
  45. {
  46.     UI_ELEMENT *nextElement = element->Next();
  47.  
  48.     // Delete the element from the use list.
  49.     UI_LIST::Subtract(element);
  50.     freeList.Add(0, element);
  51.  
  52.     // Return the next element.
  53.     return (nextElement);
  54. }
  55.