在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
function TSuperAvlTree.Search(const k: SOString; st: TSuperAvlSearchTypes): TSuperAvlEntry;
var cmp, target_cmp: integer; match_h, h: TSuperAvlEntry; ha: Cardinal; begin ha := TSuperAvlEntry.Hash(k); match_h := nil; h := FRoot; if (stLess in st) then target_cmp := 1 else if (stGreater in st) then target_cmp := -1 else target_cmp := 0; while (h <> nil) do begin // modify by mofen if nowSortMode = sosmDefault then begin //original code if h.FHash < ha then cmp := -1 else if h.FHash > ha then cmp := 1 else cmp := 0; end else begin // modify by mofen cmp := CompareForSortModeString(k, h.Name); end; ........ function TSuperAvlTree.Delete(const k: SOString): ISuperObject; var depth, rm_depth: longint; branch: TSuperAvlBitArray; h, parent, child, path, rm, parent_rm: TSuperAvlEntry; cmp, cmp_shortened_sub_with_path, reduced_depth, bf: integer; ha: Cardinal; begin ha := TSuperAvlEntry.Hash(k); cmp_shortened_sub_with_path := 0; branch := []; depth := 0; h := FRoot; parent := nil; while true do begin if (h = nil) then exit; // if h.FHash < ha then cmp := -1 else // if h.FHash > ha then cmp := 1 else // cmp := 0; // modify by mofen if nowSortMode = sosmDefault then begin //original code if h.FHash < ha then cmp := -1 else if h.FHash > ha then cmp := 1 else cmp := 0; end else begin // modify by mofen cmp := CompareForSortModeString(k, h.Name); end; ......... 再经过修改Search和Delete后 经过测试基本都可以达到了, 唯一还有一个sosmAdd模式时,进行取值时取不到, 原因是在比较compare是,如果是sosmAdd时返回的结果都是1,就是向后查找,因为按Add模式排序时,在查找时并不能进行比较查找,而是需要查询所有的节点。 这样可想而知查询的速度势必有所影响。还没有仔细研究代码。sosmAdd还不能正常使用. 其他模式没有问题。
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论