CREATE OR REPLACE PACKAGE heap_sort_pkg
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供隆昌網(wǎng)站建設(shè)、隆昌做網(wǎng)站、隆昌網(wǎng)站設(shè)計(jì)、隆昌網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、隆昌企業(yè)網(wǎng)站模板建站服務(wù),十年隆昌做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。AS
TYPE num_arr_tt IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
PROCEDURE add_nums(num_arr_inst IN OUT num_arr_tt, dvalue INT);
PROCEDURE del_nums(num_arr_inst IN OUT num_arr_tt);
FUNCTION get_maxval(num_arr_int IN OUT num_arr_tt) RETURN INT;
END heap_sort_pkg;
CREATE OR REPLACE PACKAGE BODY heap_sort_pkg
AS
PROCEDURE add_nums(num_arr_inst IN OUT num_arr_tt, dvalue INT)
AS
dest_loc INT := num_arr_inst.count + 1;
tmp_loc INT := trunc(dest_loc / 2);
BEGIN
WHILE(tmp_loc > 0 AND dvalue > num_arr_inst(tmp_loc)) LOOP
num_arr_inst(dest_loc) := num_arr_inst(tmp_loc);
dest_loc := tmp_loc;
tmp_loc := trunc(dest_loc / 2);
END LOOP;
num_arr_inst(dest_loc) := dvalue;
END add_nums;
PROCEDURE del_nums(num_arr_inst IN OUT num_arr_tt)
AS
lvalue INT;
rvalue INT;
umark INT := 1;
tmark INT := umark;
tvalue INT := num_arr_inst(num_arr_inst.count);
BEGIN
IF(num_arr_inst.count <= 1) THEN
num_arr_inst.delete(1);
dbms_output.put_line('只有一個值或無值');
RETURN;
END IF;
num_arr_inst.delete(num_arr_inst.count);
lvalue := umark * 2;
rvalue := umark * 2 + 1;
WHILE(umark <= num_arr_inst.count/2) LOOP
IF(num_arr_inst.exists(lvalue) AND num_arr_inst.exists(rvalue) AND num_arr_inst(lvalue) < num_arr_inst(rvalue)) THEN
tmark := rvalue;
ELSE
tmark := lvalue;
END IF;
IF(tvalue < num_arr_inst(tmark)) THEN
num_arr_inst(umark) := num_arr_inst(tmark);
ELSE
EXIT;
END IF;
umark := tmark;
lvalue := umark * 2;
rvalue := umark * 2 + 1;
END LOOP;
num_arr_inst(umark) := tvalue;
END del_nums;
FUNCTION get_maxval(num_arr_int IN OUT num_arr_tt) RETURN INT
AS
max_value INT := -1;
BEGIN
IF(num_arr_int.exists(1)) THEN
max_value := num_arr_int(1);
del_nums(num_arr_int);
END IF;
RETURN max_value;
END get_maxval;
END heap_sort_pkg;
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。