Showing
2 changed files
with
15 additions
and
12 deletions
@@ -46,10 +46,9 @@ TR_heapGet(TR_Heap this) | @@ -46,10 +46,9 @@ TR_heapGet(TR_Heap this) | ||
46 | return value; | 46 | return value; |
47 | } | 47 | } |
48 | 48 | ||
49 | - SWAP( | ||
50 | - void *, | ||
51 | - TR_darrGet((TR_Dynarray)this, 0), | ||
52 | - TR_darrGet((TR_Dynarray)this, idx)); | 49 | + const void * tmp = TR_darrGet((TR_Dynarray)this, 0); |
50 | + TR_darrPutAt((TR_Dynarray)this, TR_darrGet((TR_Dynarray)this, idx), 0); | ||
51 | + TR_darrPutAt((TR_Dynarray)this, tmp, idx); | ||
53 | idx = 0; | 52 | idx = 0; |
54 | 53 | ||
55 | while (left < ((TR_Dynarray)this)->size && | 54 | while (left < ((TR_Dynarray)this)->size && |
@@ -67,10 +66,12 @@ TR_heapGet(TR_Heap this) | @@ -67,10 +66,12 @@ TR_heapGet(TR_Heap this) | ||
67 | if (0 > this->comp( | 66 | if (0 > this->comp( |
68 | TR_darrGet((TR_Dynarray)this, idx), | 67 | TR_darrGet((TR_Dynarray)this, idx), |
69 | TR_darrGet((TR_Dynarray)this, change))) { | 68 | TR_darrGet((TR_Dynarray)this, change))) { |
70 | - SWAP( | ||
71 | - void *, | 69 | + tmp = TR_darrGet((TR_Dynarray)this, change); |
70 | + TR_darrPutAt( | ||
71 | + (TR_Dynarray)this, | ||
72 | TR_darrGet((TR_Dynarray)this, idx), | 72 | TR_darrGet((TR_Dynarray)this, idx), |
73 | - TR_darrGet((TR_Dynarray)this, change)); | 73 | + change); |
74 | + TR_darrPutAt((TR_Dynarray)this, tmp, idx); | ||
74 | idx = change; | 75 | idx = change; |
75 | left = (idx << 1) + 1; | 76 | left = (idx << 1) + 1; |
76 | right = left + 1; | 77 | right = left + 1; |
@@ -36,12 +36,14 @@ TR_heapPut(TR_Heap this, const void * data) | @@ -36,12 +36,14 @@ TR_heapPut(TR_Heap this, const void * data) | ||
36 | size_t parent = (idx - 1) >> 1; | 36 | size_t parent = (idx - 1) >> 1; |
37 | 37 | ||
38 | if (0 > this->comp( | 38 | if (0 > this->comp( |
39 | - TR_darrGet((TR_Dynarray)this, parent), | 39 | + TR_darrGet((TR_Dynarray)this, parent), |
40 | TR_darrGet((TR_Dynarray)this, idx))) { | 40 | TR_darrGet((TR_Dynarray)this, idx))) { |
41 | - SWAP( | ||
42 | - void *, | ||
43 | - TR_darrGet((TR_Dynarray)this, parent), | ||
44 | - TR_darrGet((TR_Dynarray)this, idx)); | 41 | + const void * tmp = TR_darrGet((TR_Dynarray)this, parent); |
42 | + TR_darrPutAt( | ||
43 | + (TR_Dynarray)this, | ||
44 | + TR_darrGet((TR_Dynarray)this, idx), | ||
45 | + parent); | ||
46 | + TR_darrPutAt((TR_Dynarray)this, tmp, idx); | ||
45 | idx = parent; | 47 | idx = parent; |
46 | } else { | 48 | } else { |
47 | break; | 49 | break; |
Please
register
or
login
to post a comment