5 #if G_AUTOPTION_ON_WINDOWS
9 #include "g_cont_private_data_pointer.h"
10 #include "g_cont_AllocationPolicyAbstract.h"
12 #define VECTOR_ALLOC_DELTA 16 //MUST be power of 2
19 template <
class T ,
class IT ,
class IT_C >
class vect;
27 data ( aAllocPolicyP ) ,
32 aAllocRightBits = ( aAllocRightBits < 1 )?1:aAllocRightBits;
33 allocDelta = 1 << aAllocRightBits;
53 return G_CONT_INDEX_NOT_VALID;
65 return G_CONT_INDEX_NOT_VALID;
69 size_t size ( ) {
return ubound-lbound+1; }
72 int abs_index (
const T* aItem )
76 int delta = ( int ) ( aItem - data );
78 return ( delta >= 0 && delta < (
int)size() )?delta:-1;
89 for (
int i = 0 ; i < (int)size() ; i++ )
108 void changeCapacity (
size_t aNewCapacity )
110 data.allocate ( aNewCapacity , capacity );
111 capacity = aNewCapacity;
114 void reserveBytes (
int aLbound ,
int aUbound )
118 changeCapacity ( (
size_t)required_capacity );
121 void pushAfter (
int aIndex ,
const T& aItem )
123 reserveBytes ( lbound , ubound + 1 );
125 move_data ( data + aIndex + 1 , data + aIndex + 2 , size() - aIndex - 1 );
127 new ( data + aIndex + 1 ) T ( aItem );
132 void setSize (
int aLbound ,
int aUbound )
134 G_EXC_SET_CONTEXT (
"void g::cont::vect_content<T>::setSize ( int aLbound , int aUbound )" );
138 if ( aUbound >= aLbound )
140 int new_size = aUbound - aLbound + 1;
142 reserveBytes ( aLbound , aUbound );
144 for (
int i = 0 ; i < new_size ; i++ )
146 new ( data + i ) T();
152 else if ( aUbound != -1 || aLbound != 0 )
154 G_EXC_RAISE_CONT (
"Lbound > ubound!" );
158 void replaceContent (
int aLbound ,
int aUbound ,
const T* aOtherDataP )
162 reserveBytes ( aLbound , aUbound );
164 for (
int i = aLbound ; i <= aUbound ; i++ )
166 new ( data + i - aLbound ) T (aOtherDataP[i]);
173 void resize (
int aLbound ,
int aUbound )
177 setSize ( aLbound , aUbound );
179 else if ( aUbound >= aLbound )
182 int start = ( aLbound >= lbound ) ? aLbound : lbound;
183 int stop = ( aUbound <= ubound ) ? aUbound : ubound;
184 int size_to_move = stop - start + 1;
187 reserveBytes ( aLbound , aUbound );
190 for (
int i = 0 ; i < start - lbound ; i++ )
192 ( data + i - lbound )->~T();
195 for (
int i = stop + 1 ; i <= ubound ; i++ )
197 ( data + i - lbound )->~T();
200 move_data ( data + start - lbound , data + start - aLbound , size_to_move );
203 for (
int i = aLbound ; i < start ; i++ )
205 new ( data - aLbound + i ) T();
209 for (
int i = stop + 1 ; i <= aUbound ; i++ )
211 new ( data - aLbound + i )T();
223 T
remove (
int aIndex )
225 T result = *( data + aIndex );
227 ( data + aIndex )->~T();
229 move_data ( data + aIndex + 1 , data + aIndex , size() - aIndex - 1 );
243 virtual int first ( )
const {
return vectorContentP->first(); }
244 virtual int last ( )
const {
return vectorContentP->last(); }
246 virtual bool isIn (
int aIndex )
const
248 return ( aIndex >= vectorContentP->lbound && aIndex <= vectorContentP->ubound );
251 virtual void forward (
int& aItem , GUint32_t aInc )
const
256 virtual void backward (
int& aItem , GUint32_t aDec )
const
261 virtual T* getPtr (
int aIndex )
const
263 if ( !vectorContentP->data )
269 return vectorContentP->data - vectorContentP->lbound + aIndex;
Definition: g_cont_AllocationPolicyAbstract.h:16
Definition: g.mthread.ThreadSimpleEvent.h:5
Definition: g_cont_common.h:52
T get_rounded_by_power_of_2(T value, T delta)
f(v,d) is the next multiple of d(MUST be a power of 2), which is k*d>=v && (k-1)*d
Definition: g_common_functions.h:104
Definition: g_cont_private_data_pointer.h:14
#define G_EXC_SET_CONTEXT(acontextstr)
Sets the method context.
Definition: g_exception_macros.h:52
Definition: g_cont_vect_priv.h:24
Definition: g_cont_vect_priv.h:237