In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
CREATE OR REPLACE PACKAGE KMP_ALGOR_PKG
AS
TYPE next_arr_tt IS TABLE OF INT INDEX BY PLS_INTEGER;
PROCEDURE match_str(org_str VARCHAR2, pat_str VARCHAR2);
FUNCTION get_pre_arr(pat_st VARCHAR2) RETURN next_arr_tt;
END kmp_algor_pkg;
CREATE OR REPLACE PACKAGE BODY KMP_ALGOR_PKG
AS
PROCEDURE match_str(org_str VARCHAR2, pat_str VARCHAR2)
AS
pat_next_arr next_arr_tt := get_pre_arr(pat_st => pat_str);
k INT := 0;
seq_cnt INT := 0;
BEGIN
FOR i IN 1.. length(org_str) LOOP
WHILE(k > 0 AND substr(org_str, i, 1) substr(pat_str, k + 1, 1)) LOOP
k := pat_next_arr(k-1);
END LOOP;
IF(substr(pat_str, k + 1, 1) = substr(org_str, i, 1)) THEN
k := k + 1;
END IF;
IF(k = length(pat_str)) THEN
seq_cnt := seq_cnt + 1;
dbms_output.put_line('the '||pat_str||' '||seq_cnt||'th match found in '||org_str||' at index '||(i - k + 1));
k := pat_next_arr(k - 1);
END IF;
END LOOP;
IF(seq_cnt = 0) THEN
dbms_output.put_line('no match found');
END IF;
END match_str;
FUNCTION get_pre_arr(pat_st VARCHAR2) RETURN next_arr_tt
AS
ret_next_arr next_arr_tt;
k INT := 0;
BEGIN
ret_next_arr(0) := 0;
FOR umark IN 1.. length(pat_st) - 1 LOOP
WHILE(k > 0 AND substr(pat_st, umark + 1 , 1) substr(pat_st, k + 1, 1)) LOOP
k := ret_next_arr(k - 1);
END LOOP;
IF(substr(pat_st, k + 1, 1) = substr(pat_st, umark + 1, 1)) THEN
k := k + 1;
END IF;
ret_next_arr(umark) := k;
END LOOP;
RETURN ret_next_arr;
END get_pre_arr;
END kmp_algor_pkg;
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.