界面库

更新
This commit is contained in:
JianjunLiu 2023-07-25 17:33:16 +08:00
parent 1f0b624609
commit c4f3f973d1
2 changed files with 77 additions and 52 deletions

View File

@ -934,7 +934,7 @@ type tnumindexarray = Class() //ջģ
len := fdlength;
for i := len-1 downto 0 do
begin
if v=FData[i]then return i;
if v=FData[i] then return i;
end
return -1;
end
@ -1005,11 +1005,13 @@ type tnumindexarray = Class() //ջģ
if not(vs) and length(vs) then return r;
r := fdlength;
r1 := r;
for i := 0 to length(vs)-1 do
begin
FData[r]:= vs[i];
r++;
end
FData union=vs;
r := length(FData);
//for i,v in vs do //20230724 修改 减少循环
//begin
// FData[r]:= v;
// r++;
//end
fdlength := r;
if r1 <> r then LengthChanged(r1-r);
return r;
@ -1055,6 +1057,16 @@ type tnumindexarray = Class() //ջģ
if len <> fdlength then LengthChanged(fdlength-len);
return r;
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;
begin
end
@ -1729,6 +1741,7 @@ type TTire = class
FSub;
FEnd;
Ficase;
_tag;
function Create(v);
begin
FChar := v;
@ -1749,10 +1762,11 @@ type TTire = class
end
ls := length(s);
if ls>1 then
vsub.Add(s[2:]);
return vsub.Add(s[2:]);
else
begin
vsub.FEnd := true;
return vsub;
end
end
function Find(s,slen,idx);
@ -1768,6 +1782,19 @@ type TTire = class
end
return FEnd ;
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);
begin
ni := i?true:false;
@ -1793,7 +1820,7 @@ type TTire = class
end
function Add(s);
begin
FRoot.Add(s);
return FRoot.Add(s);
end
function Create();
begin
@ -1801,6 +1828,11 @@ type TTire = class
FRoot := new TTireNode();
FRoot.Ficase := false;
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);
begin
tid := idx;
@ -2275,9 +2307,7 @@ type tstr_step_match=class()
**}
function create(its); //送入匹配的字符串数组
begin
fits := array();
findstaks := array();
findidxs := array("");
fits := array();
set_items(its);
end
function step_find_idx(s:string); //匹配的序号
@ -2287,34 +2317,19 @@ type tstr_step_match=class()
@param(s)(string) 匹配的目标 %%
@return(array of integer) 成功的位置 %%
**}
idx := 0;
d := getsdata(s);
if ifarray(d) then return d; //已经存在了,返回
for i := 1 to length(s) do //失效判断
if not ftree then return array();
o := ftree.find_node(s,idx);
if o and ((idx-1)=length(s)) then return o._tag;
if not o then o := ftree.FRoot;
for i := idx to length(s) do
begin
si := s[1:i];
if findidxs[i]<>si then //判断失效位置
begin
findidxs := findidxs[0:(i-1)];
break;
end
oi := ftree.add(si);
asi := get_same_idexs(si,o._tag);
oi._tag := asi;
o := oi;
end
for i:= length(findidxs) to length(s) do //从有效位置开始处理
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[];
return o._tag;
end
function step_find(s); //查找匹配的字符
begin
@ -2325,11 +2340,24 @@ type tstr_step_match=class()
if fits<> its and check_legal(its) then
begin
fits := its;
findstaks := array(0->(length(fits)-1));
findidxs := array("");
ftree := new TTire();
ftree.FRoot._tag := mrows(fits,1);
end
end
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;//判断相等
begin
return pos(a,fits[ b]);
@ -2338,17 +2366,10 @@ type tstr_step_match=class()
begin
return ifarray(its);
end
function getsdata(s);//获取成功的位置
begin
for i,v in findidxs do
begin
if v=s then return findstaks[i];
end
end
private
protected
fits; //原始数据
findstaks; //历史匹配记录
findidxs;//字符串
ftree;
private
end
implementation
function iffuncptr(fn);

View File

@ -3801,7 +3801,8 @@ type TcustomListBox=class(TCustomListBoxbase)
end
function clean();virtual;
begin
FitemData.splice(0,FitemData.Length());
//FitemData.splice(0,FitemData.Length());
FitemData := new tnumindexarray();
cleanAllSelectedState();
class(TCustomListBoxbase).ItemCount := 0;
end
@ -3827,11 +3828,14 @@ type TcustomListBox=class(TCustomListBoxbase)
protected
function CheckListItems(s);
begin
if ifarray(s)then
if ifarray(s) then
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;
end else
end
return 0;
end
function CheckListItem(s);virtual;