parent
1f0b624609
commit
c4f3f973d1
|
|
@ -934,7 +934,7 @@ type tnumindexarray = Class() //ջģ
|
||||||
len := fdlength;
|
len := fdlength;
|
||||||
for i := len-1 downto 0 do
|
for i := len-1 downto 0 do
|
||||||
begin
|
begin
|
||||||
if v=FData[i]then return i;
|
if v=FData[i] then return i;
|
||||||
end
|
end
|
||||||
return -1;
|
return -1;
|
||||||
end
|
end
|
||||||
|
|
@ -1005,11 +1005,13 @@ type tnumindexarray = Class() //ջģ
|
||||||
if not(vs) and length(vs) then return r;
|
if not(vs) and length(vs) then return r;
|
||||||
r := fdlength;
|
r := fdlength;
|
||||||
r1 := r;
|
r1 := r;
|
||||||
for i := 0 to length(vs)-1 do
|
FData union=vs;
|
||||||
begin
|
r := length(FData);
|
||||||
FData[r]:= vs[i];
|
//for i,v in vs do //20230724 修改 减少循环
|
||||||
r++;
|
//begin
|
||||||
end
|
// FData[r]:= v;
|
||||||
|
// r++;
|
||||||
|
//end
|
||||||
fdlength := r;
|
fdlength := r;
|
||||||
if r1 <> r then LengthChanged(r1-r);
|
if r1 <> r then LengthChanged(r1-r);
|
||||||
return r;
|
return r;
|
||||||
|
|
@ -1055,6 +1057,16 @@ type tnumindexarray = Class() //ջģ
|
||||||
if len <> fdlength then LengthChanged(fdlength-len);
|
if len <> fdlength then LengthChanged(fdlength-len);
|
||||||
return r;
|
return r;
|
||||||
end
|
end
|
||||||
|
function set_len(n); //设置长度
|
||||||
|
begin
|
||||||
|
if fdlength<>n and n>=0 then
|
||||||
|
begin
|
||||||
|
ol := fdlength;
|
||||||
|
fdlength := n;
|
||||||
|
FData := nils(n);
|
||||||
|
LengthChanged(n-ol);
|
||||||
|
end
|
||||||
|
end
|
||||||
function LengthChanged(n);virtual;
|
function LengthChanged(n);virtual;
|
||||||
begin
|
begin
|
||||||
end
|
end
|
||||||
|
|
@ -1729,6 +1741,7 @@ type TTire = class
|
||||||
FSub;
|
FSub;
|
||||||
FEnd;
|
FEnd;
|
||||||
Ficase;
|
Ficase;
|
||||||
|
_tag;
|
||||||
function Create(v);
|
function Create(v);
|
||||||
begin
|
begin
|
||||||
FChar := v;
|
FChar := v;
|
||||||
|
|
@ -1749,10 +1762,11 @@ type TTire = class
|
||||||
end
|
end
|
||||||
ls := length(s);
|
ls := length(s);
|
||||||
if ls>1 then
|
if ls>1 then
|
||||||
vsub.Add(s[2:]);
|
return vsub.Add(s[2:]);
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
vsub.FEnd := true;
|
vsub.FEnd := true;
|
||||||
|
return vsub;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Find(s,slen,idx);
|
function Find(s,slen,idx);
|
||||||
|
|
@ -1768,6 +1782,19 @@ type TTire = class
|
||||||
end
|
end
|
||||||
return FEnd ;
|
return FEnd ;
|
||||||
end
|
end
|
||||||
|
function find_node(s,slen,idx);
|
||||||
|
begin
|
||||||
|
if idx>slen then return (FEnd?self:0);
|
||||||
|
v0 := s[idx];
|
||||||
|
if Ficase then v0 := lowercase(v0);
|
||||||
|
vsub := FSub[v0];
|
||||||
|
if vsub then
|
||||||
|
begin
|
||||||
|
idx++;
|
||||||
|
return vsub.find_node(s,slen,idx);
|
||||||
|
end
|
||||||
|
return (FEnd?self:0);
|
||||||
|
end
|
||||||
function seticase(i);
|
function seticase(i);
|
||||||
begin
|
begin
|
||||||
ni := i?true:false;
|
ni := i?true:false;
|
||||||
|
|
@ -1793,7 +1820,7 @@ type TTire = class
|
||||||
end
|
end
|
||||||
function Add(s);
|
function Add(s);
|
||||||
begin
|
begin
|
||||||
FRoot.Add(s);
|
return FRoot.Add(s);
|
||||||
end
|
end
|
||||||
function Create();
|
function Create();
|
||||||
begin
|
begin
|
||||||
|
|
@ -1801,6 +1828,11 @@ type TTire = class
|
||||||
FRoot := new TTireNode();
|
FRoot := new TTireNode();
|
||||||
FRoot.Ficase := false;
|
FRoot.Ficase := false;
|
||||||
end
|
end
|
||||||
|
function find_node(s,oidx);
|
||||||
|
begin
|
||||||
|
oidx := 1;
|
||||||
|
return FRoot.find_node(s,length(s),oidx);
|
||||||
|
end
|
||||||
function Find(s,slen,idx,outidx,ostr);
|
function Find(s,slen,idx,outidx,ostr);
|
||||||
begin
|
begin
|
||||||
tid := idx;
|
tid := idx;
|
||||||
|
|
@ -2275,9 +2307,7 @@ type tstr_step_match=class()
|
||||||
**}
|
**}
|
||||||
function create(its); //送入匹配的字符串数组
|
function create(its); //送入匹配的字符串数组
|
||||||
begin
|
begin
|
||||||
fits := array();
|
fits := array();
|
||||||
findstaks := array();
|
|
||||||
findidxs := array("");
|
|
||||||
set_items(its);
|
set_items(its);
|
||||||
end
|
end
|
||||||
function step_find_idx(s:string); //匹配的序号
|
function step_find_idx(s:string); //匹配的序号
|
||||||
|
|
@ -2287,34 +2317,19 @@ type tstr_step_match=class()
|
||||||
@param(s)(string) 匹配的目标 %%
|
@param(s)(string) 匹配的目标 %%
|
||||||
@return(array of integer) 成功的位置 %%
|
@return(array of integer) 成功的位置 %%
|
||||||
**}
|
**}
|
||||||
idx := 0;
|
if not ftree then return array();
|
||||||
d := getsdata(s);
|
o := ftree.find_node(s,idx);
|
||||||
if ifarray(d) then return d; //已经存在了,返回
|
if o and ((idx-1)=length(s)) then return o._tag;
|
||||||
for i := 1 to length(s) do //失效判断
|
if not o then o := ftree.FRoot;
|
||||||
|
for i := idx to length(s) do
|
||||||
begin
|
begin
|
||||||
si := s[1:i];
|
si := s[1:i];
|
||||||
if findidxs[i]<>si then //判断失效位置
|
oi := ftree.add(si);
|
||||||
begin
|
asi := get_same_idexs(si,o._tag);
|
||||||
findidxs := findidxs[0:(i-1)];
|
oi._tag := asi;
|
||||||
break;
|
o := oi;
|
||||||
end
|
|
||||||
end
|
end
|
||||||
for i:= length(findidxs) to length(s) do //从有效位置开始处理
|
return o._tag;
|
||||||
begin
|
|
||||||
si := s[1:i];
|
|
||||||
asi := array();
|
|
||||||
asidx := 0;
|
|
||||||
for ii,v in findstaks[i-1] do //判断每个值
|
|
||||||
begin
|
|
||||||
if checksame(si,v) then
|
|
||||||
begin
|
|
||||||
asi[asidx++] := v;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
findstaks[i] := asi; //得到新的值
|
|
||||||
findidxs[i] := si;
|
|
||||||
end
|
|
||||||
return findstaks[length(findidxs)-1];//fits[];
|
|
||||||
end
|
end
|
||||||
function step_find(s); //查找匹配的字符
|
function step_find(s); //查找匹配的字符
|
||||||
begin
|
begin
|
||||||
|
|
@ -2325,11 +2340,24 @@ type tstr_step_match=class()
|
||||||
if fits<> its and check_legal(its) then
|
if fits<> its and check_legal(its) then
|
||||||
begin
|
begin
|
||||||
fits := its;
|
fits := its;
|
||||||
findstaks := array(0->(length(fits)-1));
|
ftree := new TTire();
|
||||||
findidxs := array("");
|
ftree.FRoot._tag := mrows(fits,1);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
|
function get_same_idexs(si,idxs);virtual; //直接判断全部
|
||||||
|
begin
|
||||||
|
asi := array();
|
||||||
|
asidx := 0;
|
||||||
|
for ii,v in idxs do
|
||||||
|
begin
|
||||||
|
if checksame(si,v) then
|
||||||
|
begin
|
||||||
|
asi[asidx++] := v;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return asi;
|
||||||
|
end
|
||||||
function checksame(a,b);virtual;//判断相等
|
function checksame(a,b);virtual;//判断相等
|
||||||
begin
|
begin
|
||||||
return pos(a,fits[ b]);
|
return pos(a,fits[ b]);
|
||||||
|
|
@ -2338,17 +2366,10 @@ type tstr_step_match=class()
|
||||||
begin
|
begin
|
||||||
return ifarray(its);
|
return ifarray(its);
|
||||||
end
|
end
|
||||||
function getsdata(s);//获取成功的位置
|
protected
|
||||||
begin
|
|
||||||
for i,v in findidxs do
|
|
||||||
begin
|
|
||||||
if v=s then return findstaks[i];
|
|
||||||
end
|
|
||||||
end
|
|
||||||
private
|
|
||||||
fits; //原始数据
|
fits; //原始数据
|
||||||
findstaks; //历史匹配记录
|
ftree;
|
||||||
findidxs;//字符串
|
private
|
||||||
end
|
end
|
||||||
implementation
|
implementation
|
||||||
function iffuncptr(fn);
|
function iffuncptr(fn);
|
||||||
|
|
|
||||||
|
|
@ -3801,7 +3801,8 @@ type TcustomListBox=class(TCustomListBoxbase)
|
||||||
end
|
end
|
||||||
function clean();virtual;
|
function clean();virtual;
|
||||||
begin
|
begin
|
||||||
FitemData.splice(0,FitemData.Length());
|
//FitemData.splice(0,FitemData.Length());
|
||||||
|
FitemData := new tnumindexarray();
|
||||||
cleanAllSelectedState();
|
cleanAllSelectedState();
|
||||||
class(TCustomListBoxbase).ItemCount := 0;
|
class(TCustomListBoxbase).ItemCount := 0;
|
||||||
end
|
end
|
||||||
|
|
@ -3827,11 +3828,14 @@ type TcustomListBox=class(TCustomListBoxbase)
|
||||||
protected
|
protected
|
||||||
function CheckListItems(s);
|
function CheckListItems(s);
|
||||||
begin
|
begin
|
||||||
if ifarray(s)then
|
if ifarray(s) then
|
||||||
begin
|
begin
|
||||||
for i := 0 to length(s)-1 do if not CheckListItem(s[i])then return 0;
|
if ((thisfunction(class(TcustomListBox).checklistitem))<>(thisfunction(self.checklistitem))) then
|
||||||
|
begin
|
||||||
|
for i,v in s do if not CheckListItem(v) then return 0;
|
||||||
|
end
|
||||||
return 1;
|
return 1;
|
||||||
end else
|
end
|
||||||
return 0;
|
return 0;
|
||||||
end
|
end
|
||||||
function CheckListItem(s);virtual;
|
function CheckListItem(s);virtual;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue