~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/bullet2/src/LinearMath/btAlignedObjectArray.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#define BT_USE_PLACEMENT_NEW 1
30
30
//#define BT_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in <memory.h> or <string.h> or otherwise...
 
31
#define BT_ALLOW_ARRAY_COPY_OPERATOR // enabling this can accidently perform deep copies of data if you are not careful
31
32
 
32
33
#ifdef BT_USE_MEMCPY
33
34
#include <memory.h>
53
54
        //PCK: added this line
54
55
        bool                            m_ownsMemory;
55
56
 
56
 
        protected:
 
57
#ifdef BT_ALLOW_ARRAY_COPY_OPERATOR
 
58
public:
 
59
        SIMD_FORCE_INLINE btAlignedObjectArray<T>& operator=(const btAlignedObjectArray<T> &other)
 
60
        {
 
61
                copyFromArray(other);
 
62
                return *this;
 
63
        }
 
64
#else//BT_ALLOW_ARRAY_COPY_OPERATOR
 
65
private:
 
66
                SIMD_FORCE_INLINE btAlignedObjectArray<T>& operator=(const btAlignedObjectArray<T> &other);
 
67
#endif//BT_ALLOW_ARRAY_COPY_OPERATOR
 
68
 
 
69
protected:
57
70
                SIMD_FORCE_INLINE       int     allocSize(int size)
58
71
                {
59
72
                        return (size ? size*2 : 1);
140
153
                
141
154
                SIMD_FORCE_INLINE const T& at(int n) const
142
155
                {
 
156
                        btAssert(n>=0);
 
157
                        btAssert(n<size());
143
158
                        return m_data[n];
144
159
                }
145
160
 
146
161
                SIMD_FORCE_INLINE T& at(int n)
147
162
                {
 
163
                        btAssert(n>=0);
 
164
                        btAssert(n<size());
148
165
                        return m_data[n];
149
166
                }
150
167
 
151
168
                SIMD_FORCE_INLINE const T& operator[](int n) const
152
169
                {
 
170
                        btAssert(n>=0);
 
171
                        btAssert(n<size());
153
172
                        return m_data[n];
154
173
                }
155
174
 
156
175
                SIMD_FORCE_INLINE T& operator[](int n)
157
176
                {
 
177
                        btAssert(n>=0);
 
178
                        btAssert(n<size());
158
179
                        return m_data[n];
159
180
                }
160
181
                
171
192
 
172
193
                SIMD_FORCE_INLINE       void    pop_back()
173
194
                {
 
195
                        btAssert(m_size>0);
174
196
                        m_size--;
175
197
                        m_data[m_size].~T();
176
198
                }
291
313
                                }
292
314
                };
293
315
        
 
316
 
294
317
                template <typename L>
295
 
                void quickSortInternal(L CompareFunc,int lo, int hi)
 
318
                void quickSortInternal(const L& CompareFunc,int lo, int hi)
296
319
                {
297
320
                //  lo is the lower index, hi is the upper index
298
321
                //  of the region of array a that is to be sorted
322
345
 
323
346
 
324
347
                template <typename L>
325
 
                void quickSort(L CompareFunc)
 
348
                void quickSort(const L& CompareFunc)
326
349
                {
327
350
                        //don't sort 0 or 1 elements
328
351
                        if (size()>1)
334
357
 
335
358
                ///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/
336
359
                template <typename L>
337
 
                void downHeap(T *pArr, int k, int n,L CompareFunc)
 
360
                void downHeap(T *pArr, int k, int n, const L& CompareFunc)
338
361
                {
339
362
                        /*  PRE: a[k+1..N] is a heap */
340
363
                        /* POST:  a[k..N]  is a heap */
380
403
                }
381
404
 
382
405
        template <typename L>
383
 
        void heapSort(L CompareFunc)
 
406
        void heapSort(const L& CompareFunc)
384
407
        {
385
408
                /* sort a[0..N-1],  N.B. 0 to N-1 */
386
409
                int k;