I'm trying to populate a VirtualStringTree. My underlying data are like this, here showing 3 of many branches, each of which has a varied number of twigs.
string 1
chunk:string 1, fname:c:\temp\file0.txt, freq:8
chunk:string 1, fname:c:\temp\file4.txt, freq:5
chunk:string 1, fname:c:\temp\file2.txt, freq:6
string 2
chunk:string 2, fname:c:\temp\file1.txt, freq:10
chunk:string 2, fname:c:\temp\file5.txt, freq:6
chunk:string 2, fname:c:\temp\file3.txt, freq:4
chunk:string 2, fname:c:\temp\file4.txt, freq:3
string 3
chunk:string 3, fname:c:\temp\file2.txt, freq:12
chunk:string 3, fname:c:\temp\file0.txt, freq:4
chunk:string 3, fname:c:\temp\file4.txt, freq:5
My query concerns how to ensure the tree knows how many different kinds of sub-nodes it needs. RootNodeCount is simple, but I don't know how to assign a varied "ChildNodeCount" without initialising all my data (in which case why use a VirtualStringTree).
My attempt has been to go through the entries in my data and using AddChild with either nil as its parameter or the last node as its parameter. That is working. But I think it isn't a virtual solution because every call to AddChild calls InitNode.
VirtualStringTreeBoiler.Clear;
VirtualStringTreeBoiler.BeginUpdate;
VirtualStringTreeBoiler.NodeDataSize := SizeOf(TBoilerRec);
repetition_seeker.BuildNodeIndex;
VirtualStringTreeBoiler.RootNodeCount := 0;
mum := nil;
MainNode := nil;
for i := 0 to repetition_seeker.NodeCount - 1 do
begin
rec := repetition_seeker.NodeIndexToMainAndSub[i];
if rec.sub_ndx<0 then
begin
MainNode := VirtualStringTreeBoiler.AddChild(mum);
MainNode.index := i;
end else begin
SubNode := VirtualStringTreeBoiler.AddChild(MainNode);
SubNode.Index := i;
end;
end;
VirtualStringTreeBoiler.EndUpdate;
Is there an efficient way to inform the tree how many children a node has -- but virtually? Could I see an example?