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
// modify by mofen
cmp := CompareForSortModeString(k, h.Name);
end;
........
function TSuperAvlTree.Delete(const k: SOString): ISuperObject;
depth, rm_depth: longint;
branch: TSuperAvlBitArray;
h, parent, child, path, rm, parent_rm: TSuperAvlEntry;
cmp, cmp_shortened_sub_with_path, reduced_depth, bf: integer;
cmp_shortened_sub_with_path := 0;
branch := [];
depth := 0;
parent := nil;
while true do
if (h = nil) then
exit;
// if h.FHash < ha then cmp := -1 else
// if h.FHash > ha then cmp := 1 else
// cmp := 0;
.........
再經過修改Search和Delete後
經過測試基本都可以達到了,
唯一還有一個sosmAdd模式時,進行取值時取不到,
原因是在比較compare是,如果是sosmAdd時傳回的結果都是1,就是向後查找,因為按Add模式排序時,在查找時并不能進行比較查找,而是需要查詢所有的節點。
這樣可想而知查詢的速度勢必有所影響。還沒有仔細研究代碼。sosmAdd還不能正常使用. 其他模式沒有問題。