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 / Maps / BCMapU.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  6.4 KB  |  199 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 bag 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. //  BCMapU.cpp
  10. //
  11. //  This file contains the definitions for the unbounded map.
  12.  
  13. #include "BCMapU.h"
  14.  
  15. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  16. BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::BC_TUnboundedMap() {}
  17.  
  18. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  19. BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  20.   BC_TUnboundedMap(BC_Index (*hash)(const Item&))
  21.     : fRep(hash) {}
  22.  
  23. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  24. BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  25.   BC_TUnboundedMap(const BC_TUnboundedMap<Item, Value, Buckets, StorageManager>& m)
  26.     : fRep(m.fRep) {}
  27.  
  28. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  29. BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::~BC_TUnboundedMap() {}
  30.  
  31. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  32. BC_TMap<Item, Value>& BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  33.   operator=(const BC_TMap<Item, Value>& m)
  34. {
  35.   return BC_TMap<Item, Value>::operator=(m);
  36. }
  37.  
  38. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  39. BC_TMap<Item, Value>& BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  40.   operator=(const BC_TUnboundedMap<Item, Value, Buckets, StorageManager>& m)
  41. {
  42.   fRep = m.fRep;
  43.   return *this;
  44. }
  45.  
  46. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  47. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  48.   operator==(const BC_TMap<Item, Value>& m) const
  49. {
  50.   return BC_TMap<Item, Value>::operator==(m);
  51. }
  52.  
  53. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  54. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  55.   operator==(const BC_TUnboundedMap<Item, Value, Buckets, StorageManager>& m) const
  56. {
  57.   return (fRep == m.fRep);
  58. }
  59.  
  60. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  61. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  62.   operator!=(const BC_TUnboundedMap<Item, Value, Buckets, StorageManager>& m) const
  63. {
  64.   return !operator==(m);
  65. }
  66.  
  67. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  68. void BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  69.   SetHashFunction(BC_Index (*hash)(const Item&))
  70. {
  71.   fRep.SetHashFunction(hash);
  72. }
  73.  
  74. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  75. void BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::Clear()
  76. {
  77.   fRep.Clear();
  78. }
  79.  
  80. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  81. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  82.   Bind(const Item& item, const Value& value)
  83. {
  84.   return fRep.Bind(item, value);
  85. }
  86.  
  87. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  88. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  89.   Rebind(const Item& item, const Value& value)
  90. {
  91.   return fRep.Rebind(item, value);
  92. }
  93.  
  94. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  95. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  96.   Unbind(const Item& item)
  97. {
  98.   return fRep.Unbind(item);
  99. }
  100. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  101. BC_Index BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::Extent() const
  102. {
  103.   return fRep.Extent();
  104. }
  105.  
  106. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  107. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::IsEmpty() const
  108. {
  109.   return (fRep.Extent() == 0);
  110. }
  111.  
  112. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  113. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  114.   IsBound(const Item& item) const
  115. {
  116.   return fRep.IsBound(item);
  117. }
  118.  
  119. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  120. const Value* BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  121.   ValueOf(const Item& item) const
  122. {
  123.   return fRep.ValueOf(item);
  124. }
  125.  
  126. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  127. Value* BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::ValueOf(const Item& item)
  128. {
  129.   return (Value*)(fRep.ValueOf(item));
  130. }
  131.  
  132. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  133. void* BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::operator new(size_t s)
  134. {
  135.   return StorageManager::Allocate(s);
  136. }
  137.  
  138. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  139. void BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  140.   operator delete(void* p, size_t s)
  141. {
  142.   StorageManager::Deallocate(p, s);
  143. }
  144.  
  145. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  146. void BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::Purge() 
  147. {
  148.   fRep.Clear();
  149. }
  150.  
  151. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  152. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  153.   Attach(const Item& item, const Value& value)
  154. {
  155.   return fRep.Bind(item, value);
  156. }
  157.  
  158. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  159. BC_Index BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  160.   NumberOfBuckets() const
  161. {
  162.   return Buckets;
  163. }
  164.  
  165. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  166. BC_Index BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  167.   Cardinality() const
  168. {
  169.   return fRep.Extent();
  170. }
  171.  
  172. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  173. BC_Index BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  174.   Length(BC_Index bucket) const
  175. {
  176.   return fRep.Bucket(bucket)->Length();
  177. }
  178.  
  179. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  180. BC_Boolean BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  181.   Exists(const Item& item) const
  182. {
  183.   return fRep.IsBound(item);
  184. }
  185.  
  186. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  187. const Item& BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  188.   ItemAt(BC_Index bucket, BC_Index index) const
  189. {
  190.   return (*fRep.Bucket(bucket))[index].fItem;
  191. }
  192.  
  193. template<class Item, class Value, BC_Index Buckets, class StorageManager>
  194. const Value& BC_TUnboundedMap<Item, Value, Buckets, StorageManager>::
  195.   ValueAt(BC_Index bucket, BC_Index index) const
  196. {
  197.   return (*fRep.Bucket(bucket))[index].fValue;
  198. }
  199.