Array.h
Go to the documentation of this file.00001 00019 #ifndef __Array_H__ 00020 #define __Array_H__ 00021 00022 // Includes 00023 00024 // Forward declares 00025 template <class TYPE> class ArrayIterator; 00026 00027 // Array 00028 template<class TYPE> 00029 class Array 00030 { 00031 public: 00035 Array( 00036 int initialCapacity = 64 00037 00038 ); 00039 00043 Array( 00044 const Array<TYPE>& arrayToCopy 00045 ); 00046 00052 const Array<TYPE>& operator = ( 00053 const Array<TYPE>& arrayToCopy 00054 ); 00055 00059 ~Array(); 00060 00066 TYPE& Add( 00067 const TYPE& item 00068 ); 00069 00075 void InsertBefore( 00076 const TYPE& item, 00077 int index 00078 ); 00079 00085 void InsertBefore( 00086 const TYPE& item, 00087 const ArrayIterator<TYPE>& insertBefore 00088 ); 00089 00095 void InsertAfter( 00096 const TYPE& item, 00097 int index 00098 00099 ); 00100 00106 void InsertAfter( 00107 const TYPE& item, 00108 const ArrayIterator<TYPE>& insertAfter 00109 ); 00110 00115 void RemoveLast(); 00116 00122 void Remove( 00123 int index 00124 ); 00125 00131 void Remove( 00132 const ArrayIterator<TYPE>& iterator 00133 ); 00134 00140 int GetItemCount() const; 00141 00148 TYPE& Get( 00149 int index 00150 ) const; 00151 00158 TYPE& Get( 00159 const ArrayIterator<TYPE>& iterator 00160 ) const; 00161 00168 void Set( 00169 int index, 00170 const TYPE& item 00171 ); 00172 00179 void Set( 00180 const ArrayIterator<TYPE>& iterator, 00181 const TYPE& item 00182 ); 00183 00189 int GetCapacity() const; 00190 00196 void SetCapacity(int capacity); 00197 00201 void Clear( 00202 bool releaseMemory = false 00203 00204 ); 00205 00211 bool ItemExists( 00212 const TYPE& item 00213 ) const; 00214 00221 TYPE* GetPointer() const; 00222 00223 00224 private: 00225 int initialCapacity_; 00226 int capacity_; 00227 int itemCount_; 00228 TYPE* items_; 00229 }; 00230 00231 // Implementation 00232 #include "Array.inl" 00233 00234 #endif /* __Array_h__ */
Reproduction/republishing of any material on this site without permission is strictly prohibited.
