53 void resizeFast(
PxArray<PxI32>& arr, PxU32 newSize, PxI32 value = 0)
55 if (newSize < arr.
size())
59 while (arr.
size() < newSize)
64 PxI32 insert(T elem, PxI32
id = -1)
70 else if (
id >= nextId)
73 if (
id >= 0 &&
id < PxI32(posOfId.
size()) && posOfId[
id] >= 0)
79 if (
id >= PxI32(posOfId.
size()))
80 resizeFast(posOfId,
id + 1, -1);
82 posOfId[id] = heap.size() - 1;
84 percolate(PxI32(heap.size()) - 1);
91 PxI32 i = posOfId[id];
98 heap[i] = heap.back();
103 if (i < PxI32(heap.size()))
126 posOfId[ids[1]] = -1;
128 heap[1] = heap.back();
142 heap.resize(elems.
size() + 1);
146 for (PxU32 i = 0; i < elems.
size(); i++)
148 heap[i + 1] = elems[i];
150 posOfId[ids[i + 1]] = i + 1;
153 PxI32 n = (heap.size() - 1) >> 1;
154 for (PxI32 i = n; i >= 1; i--)
160 heap.capacity() == 0 ? heap.resize(1) : heap.forceSize_Unsafe(1);
169 void siftDown(PxI32 i)
171 PxI32 n = PxI32(heap.size()) - 1;
177 if (2 * j < n && heap[2 * j] < heap[k])
179 if (2 * j < n && heap[2 * j + 1] < heap[k])
181 T temp = heap[j]; heap[j] = heap[k]; heap[k] = temp;
182 PxI32
id = ids[j]; ids[j] = ids[k]; ids[k] = id;
191 void percolate(PxI32 i)
198 if (j > 1 && !(heap[j >> 1] < heap[k]))
200 T temp = heap[j]; heap[j] = heap[k]; heap[k] = temp;
201 PxI32
id = ids[j]; ids[j] = ids[k]; ids[k] = id;
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39