17 #ifndef BT_OBJECT_ARRAY__
18 #define BT_OBJECT_ARRAY__
29 #define BT_USE_PLACEMENT_NEW 1
31 #define BT_ALLOW_ARRAY_COPY_OPERATOR // enabling this can accidently perform deep copies of data if you are not careful
36 #endif //BT_USE_MEMCPY
38 #ifdef BT_USE_PLACEMENT_NEW
40 #endif //BT_USE_PLACEMENT_NEW
57 #ifdef BT_ALLOW_ARRAY_COPY_OPERATOR
64 #else//BT_ALLOW_ARRAY_COPY_OPERATOR
67 #endif//BT_ALLOW_ARRAY_COPY_OPERATOR
72 return (size ? size*2 : 1);
77 for (i=start;i<end;++i)
79 new (&dest[i]) T(
m_data[i]);
82 #endif //BT_USE_PLACEMENT_NEW
96 for (i=first; i<last;i++)
141 int otherSize = otherArray.
size();
205 int curSize =
size();
207 if (newsize < curSize)
211 if (newsize >
size())
222 int curSize =
size();
224 if (newsize < curSize)
226 for(
int i = newsize; i < curSize; i++)
232 if (newsize >
size())
236 #ifdef BT_USE_PLACEMENT_NEW
237 for (
int i=curSize;i<newsize;i++)
239 new ( &
m_data[i]) T(fillData);
241 #endif //BT_USE_PLACEMENT_NEW
268 #ifdef BT_USE_PLACEMENT_NEW
269 new (&
m_data[sz]) T(fillValue);
284 #ifdef BT_USE_PLACEMENT_NEW
288 #endif //BT_USE_PLACEMENT_NEW
334 template <
typename L>
345 while (CompareFunc(
m_data[i],x))
347 while (CompareFunc(x,
m_data[j]))
364 template <
typename L>
376 template <
typename L>
377 void downHeap(T *pArr,
int k,
int n,
const L& CompareFunc)
382 T temp = pArr[k - 1];
388 if ((child < n) && CompareFunc(pArr[child - 1] , pArr[child]))
393 if (CompareFunc(temp , pArr[child - 1]))
396 pArr[k - 1] = pArr[child - 1];
407 void swap(
int index0,
int index1)
410 char temp[
sizeof(T)];
411 memcpy(temp,&
m_data[index0],
sizeof(T));
413 memcpy(&
m_data[index1],temp,
sizeof(T));
418 #endif //BT_USE_PLACEMENT_NEW
422 template <
typename L>
428 for (k = n/2; k > 0; k--)
452 while (first <= last) {
453 int mid = (first + last) / 2;
456 else if (key <
m_data[mid])
470 for (i=0;i<
size();i++)
481 void remove(
const T& key)
485 if (findIndex<
size())
504 int otherSize = otherArray.
size();
511 #endif //BT_OBJECT_ARRAY__