17#ifndef BT_OBJECT_ARRAY__
18#define BT_OBJECT_ARRAY__
29#define BT_USE_PLACEMENT_NEW 1
31#define BT_ALLOW_ARRAY_COPY_OPERATOR
38#ifdef BT_USE_PLACEMENT_NEW
43#if __cplusplus > 199711L
46#define BT_REGISTER register
63#ifdef BT_ALLOW_ARRAY_COPY_OPERATOR
83 for (i=start;i<end;++i)
85 new (&dest[i]) T(
m_data[i]);
102 for (i=first; i<last;i++)
147 int otherSize = otherArray.
size();
211 if (newsize >
size())
222 if (newsize < curSize)
224 for(
int i = newsize; i < curSize; i++)
230 if (newsize > curSize)
234#ifdef BT_USE_PLACEMENT_NEW
235 for (
int i=curSize;i<newsize;i++)
237 new ( &
m_data[i]) T(fillData);
266#ifdef BT_USE_PLACEMENT_NEW
267 new (&
m_data[sz]) T(fillValue);
282#ifdef BT_USE_PLACEMENT_NEW
332 template <
typename L>
343 while (CompareFunc(
m_data[i],x))
345 while (CompareFunc(x,
m_data[j]))
362 template <
typename L>
374 template <
typename L>
375 void downHeap(T *pArr,
int k,
int n,
const L& CompareFunc)
380 T temp = pArr[k - 1];
386 if ((child < n) && CompareFunc(pArr[child - 1] , pArr[child]))
391 if (CompareFunc(temp , pArr[child - 1]))
394 pArr[k - 1] = pArr[child - 1];
405 void swap(
int index0,
int index1)
408 char temp[
sizeof(T)];
409 memcpy(temp,&
m_data[index0],
sizeof(T));
411 memcpy(&
m_data[index1],temp,
sizeof(T));
420 template <
typename L>
426 for (k = n/2; k > 0; k--)
450 while (first <= last) {
451 int mid = (first + last) / 2;
454 else if (key <
m_data[mid])
468 for (i=0;i<
size();i++)
486 for (i=0;i<
size();i++)
523 int otherSize = otherArray.
size();
#define BT_USE_PLACEMENT_NEW
If the platform doesn't support placement new, you can disable BT_USE_PLACEMENT_NEW then the btAligne...
#define SIMD_FORCE_INLINE
The btAlignedAllocator is a portable class for aligned memory allocations.
bool operator()(const T &a, const T &b) const
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
int findLinearSearch2(const T &key) const
void resizeNoInitialize(int newsize)
resize changes the number of elements in the array.
int size() const
return the number of elements in the array
void copyFromArray(const btAlignedObjectArray &otherArray)
int findLinearSearch(const T &key) const
void resize(int newsize, const T &fillData=T())
void swap(int index0, int index1)
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
btAlignedObjectArray< T > & operator=(const btAlignedObjectArray< T > &other)
void * allocate(int size)
void removeAtIndex(int index)
void remove(const T &key)
T & expandNonInitializing()
T & expand(const T &fillValue=T())
void destroy(int first, int last)
const T & operator[](int n) const
void quickSort(const L &CompareFunc)
void copy(int start, int end, T *dest) const
void heapSort(const L &CompareFunc)
void push_back(const T &_Val)
void initializeFromBuffer(void *buffer, int size, int capacity)
int capacity() const
return the pre-allocated (reserved) elements, this is at least as large as the total number of elemen...
btAlignedAllocator< T, 16 > m_allocator
int findBinarySearch(const T &key) const
non-recursive binary search, assumes sorted array
const T & at(int n) const
btAlignedObjectArray(const btAlignedObjectArray &otherArray)
Generally it is best to avoid using the copy constructor of an btAlignedObjectArray,...
void downHeap(T *pArr, int k, int n, const L &CompareFunc)
heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/
void quickSortInternal(const L &CompareFunc, int lo, int hi)