00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef neo_core_array_h
00022 #define neo_core_array_h
00023
00027 #include "platform.h"
00028 #include "exception.h"
00029
00030 namespace neo {
00031 namespace core {
00032
00045 template < class T > class Array
00046 {
00047 public:
00048
00050 typedef T* iterator;
00051
00053 typedef const T* const_iterator;
00054
00055 typedef unsigned int size_type;
00056 typedef ptrdiff_t difference_type;
00057 typedef T& reference;
00058 typedef const T& const_reference;
00059 typedef T* pointer;
00060 typedef const T* const_pointer;
00061 typedef T value_type;
00062
00064
00067 Array( size_type num = 0 );
00068
00070
00074 Array( size_type num, const_reference val );
00075
00077
00081 Array( size_type num, const_pointer p_val );
00082
00084
00087 Array( const Array< T >& array );
00088
00090
00091 ~Array();
00092
00094
00098 inline void push_back( const_reference obj );
00099
00101
00104 inline void pop_back();
00105
00107
00112 iterator insert( const_iterator at, const_reference obj );
00113
00115
00122 iterator insert( const_iterator at, const_iterator first, const_iterator last );
00123
00125
00131 void erase( const_reference obj, bool once = true );
00132
00134
00138 iterator erase( iterator pos );
00139
00141
00147 iterator erase( iterator first, iterator last );
00148
00150
00154 void resize( size_type num );
00155
00157
00162 void resize( size_type num, const_reference val );
00163
00165
00171 void reserve( size_type num );
00172
00174
00177 void clear( bool dealloc = false );
00178
00180
00182 inline size_type size() const;
00183
00185
00187 inline size_type capacity() const;
00188
00190
00191 inline bool empty() const;
00192
00194
00197 iterator find( const T& obj );
00198
00200
00203 const_iterator find( const T& obj ) const;
00204
00206
00208 inline iterator begin();
00209
00211
00213 inline const_iterator begin() const;
00214
00216
00219 inline iterator end();
00220
00222
00225 inline const_iterator end() const;
00226
00228
00229 inline reference front();
00230
00232
00233 inline const_reference front() const;
00234
00236
00237 inline reference back();
00238
00240
00241 inline const_reference back() const;
00242
00244
00246 inline void swap( Array< T >& array );
00247
00249
00252 inline reference operator [] ( size_t index );
00253
00255
00258 inline const_reference operator [] ( size_t index ) const;
00259
00261
00264 Array< T >& operator = ( const Array< T >& array );
00265
00266 private:
00267
00268 typedef char* raw_pointer;
00269
00271 size_type _num;
00272
00274 size_type _used;
00275
00277 raw_pointer _p_arr;
00278 };
00279
00280 #include "array.inl"
00281
00283
00286 template < typename T > inline void swap( Array< T >& lval, Array< T >& rval ) { lval.swap( rval ); }
00287
00288 }
00289 }
00290
00291 #endif