home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / BCCollec / Structs / Stacks / BCStacU.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  3.5 KB  |  139 lines  |  [TEXT/MPS ]

  1. //  The C++ Booch Components (Version 2.1)
  2. //  (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
  3. //
  4. //  Restricted Rights Legend
  5. //  Use, duplication, or disclosure is subject to restrictions as set forth 
  6. //  in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer 
  7. //  Software clause at DFARS 252.227-7013. 
  8. //
  9. //  BCStacU.cpp
  10. //
  11. //  This file contains the definitions for the unbounded stack.
  12.  
  13. #include "BCStacU.h"
  14.  
  15. template<class Item, class StorageManager>
  16. BC_TUnboundedStack<Item, StorageManager>::BC_TUnboundedStack() {}
  17.  
  18. template<class Item, class StorageManager>
  19. BC_TUnboundedStack<Item, StorageManager>::
  20.   BC_TUnboundedStack(const BC_TUnboundedStack<Item, StorageManager>& s)
  21.     : fRep(s.fRep) {}
  22.  
  23. template<class Item, class StorageManager>
  24. BC_TUnboundedStack<Item, StorageManager>::~BC_TUnboundedStack() {}
  25.  
  26. template<class Item, class StorageManager>
  27. BC_TStack<Item>& BC_TUnboundedStack<Item, StorageManager>::
  28.   operator=(const BC_TStack<Item>& s)
  29. {
  30.   return BC_TStack<Item>::operator=(s);
  31. }
  32.  
  33. template<class Item, class StorageManager>
  34. BC_TStack<Item>& BC_TUnboundedStack<Item, StorageManager>::
  35.   operator=(const BC_TUnboundedStack<Item, StorageManager>& s)
  36. {
  37.   fRep = s.fRep;
  38.   return *this;
  39. }
  40.  
  41. template<class Item, class StorageManager>
  42. BC_Boolean BC_TUnboundedStack<Item, StorageManager>::
  43.   operator==(const BC_TStack<Item>& s) const
  44. {
  45.   return BC_TStack<Item>::operator==(s);
  46. }
  47.  
  48. template<class Item, class StorageManager>
  49. BC_Boolean BC_TUnboundedStack<Item, StorageManager>::
  50.   operator==(const BC_TUnboundedStack<Item, StorageManager>& s) const
  51. {
  52.   return (fRep == s.fRep);
  53. }
  54.  
  55. template<class Item, class StorageManager>
  56. BC_Boolean BC_TUnboundedStack<Item, StorageManager>::
  57.   operator!=(const BC_TUnboundedStack<Item, StorageManager>& s) const
  58. {
  59.   return !operator==(s);
  60. }
  61.  
  62. template<class Item, class StorageManager>
  63. void BC_TUnboundedStack<Item, StorageManager>::Clear()
  64. {
  65.   fRep.Clear();
  66. }
  67.  
  68. template<class Item, class StorageManager>
  69. void BC_TUnboundedStack<Item, StorageManager>::Push(const Item& item)
  70. {
  71.   fRep.Insert(item);
  72. }
  73.  
  74. template<class Item, class StorageManager>
  75. void BC_TUnboundedStack<Item, StorageManager>::Pop()
  76. {
  77.   fRep.Remove(0);
  78. }
  79.     
  80. template<class Item, class StorageManager>
  81. BC_Index BC_TUnboundedStack<Item, StorageManager>::Depth() const
  82. {
  83.   return fRep.Length();
  84. }
  85.  
  86. template<class Item, class StorageManager>
  87. BC_Boolean BC_TUnboundedStack<Item, StorageManager>::IsEmpty() const
  88. {
  89.   return (fRep.Length() == 0);
  90. }
  91.  
  92. template<class Item, class StorageManager>
  93. const Item& BC_TUnboundedStack<Item, StorageManager>::Top() const
  94. {
  95.   return fRep.First();
  96. }
  97.  
  98. template<class Item, class StorageManager>
  99. Item& BC_TUnboundedStack<Item, StorageManager>::Top()
  100. {
  101.   return fRep.First();
  102. }
  103.  
  104. template<class Item, class StorageManager>
  105. void* BC_TUnboundedStack<Item, StorageManager>::operator new(size_t s)
  106. {
  107.   return StorageManager::Allocate(s);
  108. }
  109.  
  110. template<class Item, class StorageManager>
  111. void BC_TUnboundedStack<Item, StorageManager>::operator delete(void* p, size_t s)
  112. {
  113.   StorageManager::Deallocate(p, s);
  114. }
  115.  
  116. template<class Item, class StorageManager>
  117. void BC_TUnboundedStack<Item, StorageManager>::Purge()
  118. {
  119.   fRep.Clear();
  120. }
  121.  
  122. template<class Item, class StorageManager>
  123. void BC_TUnboundedStack<Item, StorageManager>::Add(const Item& item)
  124. {
  125.   fRep.Append(item);
  126. }
  127.  
  128. template<class Item, class StorageManager>
  129. BC_Index BC_TUnboundedStack<Item, StorageManager>::Cardinality() const
  130. {
  131.   return fRep.Length();
  132. }
  133.  
  134. template<class Item, class StorageManager>
  135. const Item& BC_TUnboundedStack<Item, StorageManager>::ItemAt(BC_Index index) const
  136. {
  137.   return fRep.ItemAt(index);
  138. }
  139.