Function: ps-mode-heapsort
ps-mode-heapsort is an interactive and byte-compiled function defined
in ps-mode.el.gz.
Signature
(ps-mode-heapsort)
Documentation
Insert function /Heapsort.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ps-mode.el.gz
(defun ps-mode-heapsort ()
"Insert function /Heapsort."
(interactive)
(insert "
% `array-element' Heapsort-cvi-or-cvr-or-cvs `number-or-string'
/Heapsort-cvi-or-cvr-or-cvs {
% 0 get
} bind def
% `array' Heapsort `sorted-array'
/Heapsort {
dup length /hsR exch def
/hsL hsR 2 idiv 1 add def
{
hsR 2 lt { exit } if
hsL 1 gt {
/hsL hsL 1 sub def
} {
/hsR hsR 1 sub def
dup dup dup 0 get exch dup hsR get
0 exch put
hsR exch put
} ifelse
dup hsL 1 sub get /hsT exch def
/hsJ hsL def
{
/hsS hsJ def
/hsJ hsJ dup add def
hsJ hsR gt { exit } if
hsJ hsR lt {
dup dup hsJ 1 sub get Heapsort-cvi-or-cvr-or-cvs
exch hsJ get Heapsort-cvi-or-cvr-or-cvs
lt { /hsJ hsJ 1 add def } if
} if
dup hsJ 1 sub get Heapsort-cvi-or-cvr-or-cvs
hsT Heapsort-cvi-or-cvr-or-cvs
le { exit } if
dup dup hsS 1 sub exch hsJ 1 sub get put
} loop
dup hsS 1 sub hsT put
} loop
} bind def
"))