Handbook
Glossary
sift-up ( heap n -- )
Vocabulary
heaps
.
private
Inputs
heap
an
object
n
an
object
Outputs
None
Definition
USING:
accessors
kernel
math
math.private
sequences
;
IN:
heaps.private
::
sift-up
( heap n -- )
heap
data>>
:>
data data
length
:>
end n data
data-nth
:>
tmp n
dup
left
[
dup
end
<
]
[
dup
1
fixnum+fast
dup
end
<
[
2dup
[
data
data-nth
]
bi@
heap
heap-compare
]
[
f
]
if
[
nip
]
[
drop
]
if
[
data
data-nth
swap
data
data-set-nth
]
[
dup
left
]
bi
]
while
drop
tmp
over
data
data-set-nth
heap n
rot
sift-down
;
inline