Lines Matching refs:index

20  * Optionally objects may know their index into the priority queue. The queue will update the index
24 * afterwards. In debug builds the index will be set to -1 before an element is removed from the
68 int index = fArray.count();
71 this->percolateUpIfNecessary(index);
78 int index = *INDEX(entry);
79 SkASSERT(index >= 0 && index < fArray.count());
81 SkDEBUGCODE(*INDEX(fArray[index]) = -1;)
82 if (index == fArray.count() - 1) {
86 fArray[index] = fArray[fArray.count() - 1];
88 this->setIndex(index);
89 this->percolateUpOrDown(index);
98 int index = *INDEX(entry);
99 SkASSERT(index >= 0 && index < fArray.count());
100 this->validate(index);
101 this->percolateUpOrDown(index);
105 /** Gets the item at index i in the priority queue (for i < this->count()). at(0) is equivalent
126 void percolateUpOrDown(int index) {
127 SkASSERT(index >= 0);
128 if (!percolateUpIfNecessary(index)) {
129 this->validate(index);
130 this->percolateDownIfNecessary(index);
134 bool percolateUpIfNecessary(int index) {
135 SkASSERT(index >= 0);
138 if (0 == index) {
139 this->setIndex(index);
142 int p = ParentOf(index);
143 if (LESS(fArray[index], fArray[p])) {
145 swap(fArray[index], fArray[p]);
146 this->setIndex(index);
147 index = p;
150 this->setIndex(index);
153 this->validate(index);
157 void percolateDownIfNecessary(int index) {
158 SkASSERT(index >= 0);
160 int child = LeftOf(index);
164 this->setIndex(index);
170 if (LESS(fArray[child], fArray[index])) {
172 swap(fArray[child], fArray[index]);
174 this->setIndex(index);
183 if (LESS(fArray[child], fArray[index])) {
185 swap(fArray[child], fArray[index]);
186 this->setIndex(index);
187 index = child;
190 this->setIndex(index);
193 this->validate(index);
197 void setIndex(int index) {
198 SkASSERT(index < fArray.count());
200 *INDEX(fArray[index]) = index;