我有一个像
target_results : TDictionary<longint,double>;
填充后,我需要对结果进行排序。我正在这样做
type
TSearchResult = TPair<longint,double>;
var
target_results_array : TArray<TSearchResult>;
target_results_array:= target_results.ToArray;
TArray.Sort<TSearchResult>(best_knowledge_search_results,
TComparer<TSearchResult>.Construct(
function(const L, R: TSearchResult): Integer
begin
if L.Value < R.Value then Result := 1 else if L.Value > R.Value then Result := -1 else Result := 0;
end
));
这一切都按预期工作。我的问题是如何处理 TDictionary 和 TArray 而不会泄漏?目前我只是在做
target_results.Free;