Cosmetics.
This commit is contained in:
1 parent
0e421a6eef
commit
7e14b78afa
1 file changed
+10
-7
+10
-7
@@ -8,21 +8,21 @@
|
|||||||
|
|
||||||
#import "MP42Heap.h"
|
#import "MP42Heap.h"
|
||||||
|
|
||||||
void swap(id *i, id *j) {
|
static void swap(id *i, id *j) {
|
||||||
id temp = *i;
|
id temp = *i;
|
||||||
*i = *j;
|
*i = *j;
|
||||||
*j = temp;
|
*j = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 parent(uint64 i) {
|
static uint64 parent(uint64 i) {
|
||||||
return (i + 1) / 2 - 1;
|
return (i + 1) / 2 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 left(uint64 i) {
|
static uint64 left(uint64 i) {
|
||||||
return i * 2 + 1;
|
return i * 2 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 right(uint64 i) {
|
static uint64 right(uint64 i) {
|
||||||
return i * 2 + 2;
|
return i * 2 + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +64,9 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id)extract NS_RETURNS_RETAINED {
|
- (id)extract NS_RETURNS_RETAINED {
|
||||||
if (!_len)
|
if (!_len) {
|
||||||
return nil;
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
id temp = _array[0];
|
id temp = _array[0];
|
||||||
_array[0] = _array[--_len];
|
_array[0] = _array[--_len];
|
||||||
@@ -81,10 +82,12 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
uint64 l = left(i);
|
uint64 l = left(i);
|
||||||
uint64 r = right(i);
|
uint64 r = right(i);
|
||||||
|
|
||||||
if (l < _len && _cmptr(_array[l], _array[largest]) >= NSOrderedDescending)
|
if (l < _len && _cmptr(_array[l], _array[largest]) >= NSOrderedDescending) {
|
||||||
largest = l;
|
largest = l;
|
||||||
if (r < _len && _cmptr(_array[r], _array[largest]) >= NSOrderedDescending)
|
}
|
||||||
|
if (r < _len && _cmptr(_array[r], _array[largest]) >= NSOrderedDescending) {
|
||||||
largest = r;
|
largest = r;
|
||||||
|
}
|
||||||
|
|
||||||
if (largest != i) {
|
if (largest != i) {
|
||||||
swap(&_array[i], &_array[largest]);
|
swap(&_array[i], &_array[largest]);
|
||||||
|
|||||||
Reference in new issue
Block a user