home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP10-8.ZIP / CLASSINC.ZIP / ARRAY.H < prev    next >
C/C++ Source or Header  |  1990-09-26  |  6KB  |  234 lines

  1. #ifndef __ARRAY_H
  2. #define __ARRAY_H
  3.  
  4. //
  5. // This file contains proprietary information of Borland International.
  6. // Copying or reproduction without prior written approval is prohibited.
  7. //
  8. // Copyright (c) 1990
  9. // Borland International
  10. // 1800 Scotts Valley Dr.
  11. // Scotts Valley, CA 95066
  12. // (408) 438-8400
  13. //
  14.  
  15. // Contents ----------------------------------------------------------------
  16. //
  17. //      Array
  18. //         Array::operator []
  19. //
  20. // Description
  21. //
  22. //      Defines the class Array.  An array object implies indexability.
  23. //
  24. // End ---------------------------------------------------------------------
  25.  
  26. // Interface Dependencies ---------------------------------------------------
  27.  
  28. #ifndef __IOSTREAM_H
  29. #include <iostream.h>
  30. #define __IOSTREAM_H
  31. #endif
  32.  
  33. #ifndef __CLSTYPES_H
  34. #include <clstypes.h>
  35. #endif
  36.  
  37. #ifndef __OBJECT_H
  38. #include <object.h>
  39. #endif
  40.  
  41. #ifndef __ABSTARRY_H
  42. #include <abstarry.h>
  43. #endif
  44.  
  45. // End Interface Dependencies ------------------------------------------------
  46.  
  47.  
  48. // Class //
  49.  
  50. class Array:  public AbstractArray
  51. {
  52. public:                                                         
  53.             Array( int upper, int lower = 0, sizeType aDelta = 0 ) :
  54.                                 AbstractArray( upper, lower, aDelta ) {}
  55.     virtual ~Array();
  56.  
  57.             Object&         operator []( int ) const;
  58.  
  59.     virtual void            add( Object& );
  60.             void            addAt( Object&, int );
  61.     virtual classType       isA() const;
  62.     virtual char           *nameOf() const;
  63. };
  64.  
  65. // Description -------------------------------------------------------------
  66. //
  67. //      Defines the class Array.  The Array class is made up of Objects
  68. //         which can be indexed with the given operator.  The size of the
  69. //         array, i.e. the maximum number of elements which may be put
  70. //         into the array, is calculated from the bounds given at the
  71. //         construction of the array object.
  72. //
  73. // Constructor
  74. //
  75. //         Array
  76. //
  77. //         Constructor.  Parameter upper specifies the upper bound for the
  78. //         index of the array.    Parameter lower specifies a lower bound for
  79. //         the index of the array.  Paramter aDelta specifies the number of 
  80. //         array elements by which the array will grow if an element is added 
  81. //         to an array    which has no more space for elements.  Specify aDelta = 0 
  82. //         if the array should not be allowed to grow.
  83. //
  84. // Public Members
  85. //
  86. //         operator []
  87. //
  88. //         Subscript operator.  Returns a reference to the element at the 
  89. //         given index.  The subscript operator will report an index out of
  90. //         bounds if the index is not in the current range.
  91. //
  92. //         lowerBound
  93. //
  94. //         Returns the current lower bound of the array.  The lower bound is
  95. //         fixed when the array is constructed.
  96. //
  97. //         upperBound
  98. //
  99. //         Returns the upper bound of the array.  The upper bound is initially
  100. //         set when the array is constructed but may increase is more elements
  101. //         are added.    The amount by which the upper bound will increase is
  102. //         a parameter to the constructor for the array.
  103. //
  104. //         arraySize
  105. //
  106. //         Returns the size of the array, in elements, as determined by the
  107. //         lower bound and the current upper bound.
  108. //
  109. //         addAt
  110. //
  111. //      Places an object in the array of the specified idnex, growing the
  112. //      array as needed if the index exceeds the upper bound.
  113. //
  114. //      destroy
  115. //
  116. //      Removes an object reference from the array at the given index and
  117. //      destroys the object.
  118. //
  119. //         detach
  120. //
  121. //         Removes all references to the object at the given index in the array.
  122. //      Does not delete the object.  Use this function when the array elements
  123. //         are not owned by the array.
  124. //
  125. //      add
  126. //
  127. //      Appends an object to the array, expanding the array if necessary.
  128. //      Overrides add member function inherited from Collection.
  129. //     
  130. //      destroy
  131. //
  132. //      Destroys the given object.
  133. //
  134. //         detach
  135. //
  136. //      Removes a reference to the given object from the array.
  137. //
  138. //      hashValue
  139. //
  140. //         Returns a pre-defined value as the hash value of an array.
  141. //
  142. //         isA
  143. //
  144. //         Returns the class type of an array.
  145. //
  146. //         nameOf
  147. //
  148. //         Returns a pointer to the character string "Array."
  149. //     
  150. //         isEqual
  151. //
  152. //         Determines whether two arrays are equal.
  153. //
  154. // Inherited Members
  155. //
  156. //      hasMember
  157. //
  158. //      Inherited from Collection
  159. //
  160. //         isEmpty
  161. //
  162. //      Inherited from Collection.
  163. //
  164. //      forEach
  165. //
  166. //      Inherited from Container.
  167. //
  168. //      firstThat
  169. //
  170. //      Inherited from Container.
  171. //
  172. //      lastThat
  173. //
  174. //      Inherited from Container.
  175. //
  176. //         printOn
  177. //
  178. //         Inherited from Container.
  179. //
  180. //         printHeader
  181. //
  182. //         Inherited from Object.
  183. //
  184. //         printTrailer
  185. //
  186. //         Inherited from Object.
  187. //
  188. //         printSeparator
  189. //
  190. //         Inherited from Object.
  191. //
  192. // Protected Members
  193. //
  194. //      delta
  195. //
  196. //      Defines the number of elements by which we are to expand the
  197. //      array, if needed.
  198. //
  199. //      lowerbound
  200. //
  201. //      Defines the smallest value for an index in this array.
  202. //
  203. //      upperbound
  204. //
  205. //      Defines the largest index in the array which, if referenced,
  206. //      will not cause an array expansion to take place.
  207. //
  208. //      theArray
  209. //
  210. //      Points to the area in which array element references are located.
  211. //
  212. // End ---------------------------------------------------------------------
  213.  
  214.  
  215. // Member Function //
  216.  
  217. inline Object& Array::operator []( int atIndex ) const
  218.  
  219. // Summary -----------------------------------------------------------------
  220. //
  221. //      Subscript operator for arrays.
  222. //
  223. // Return Value
  224. //
  225. //         objectAt
  226. //
  227. //         Reference to the object at the given index.
  228. //
  229. // End ---------------------------------------------------------------------
  230. {
  231.     return objectAt( atIndex );
  232. }
  233. #endif // ifndef __ARRAY_H //
  234.