TList 类的方法 Sort 是如何工作的?此方法是否仅以列表元素仅上升/下降的方式排序?请看下面的代码。
Type
PInteger = ^Integer;
Function Compare(Item1, Item2 : Pointer) : Integer;
Begin
if PInteger(Item1)^ > Pinteger(Item2)^ then Result:= 1
else if PInteger(Item1)^ < PInteger(Item2)^ then Result:= -1
else Result:= 0;
End;
{ And, for instance, somewhere we call the method }
List.Sort(Compare);
现在的问题是,在我编译代码之后,它运行良好,列表以元素升序的方式排序。但我不明白以下行:
PInteger(item1)^ // What does this represent?
item1, item2 的指针指向什么?他们不需要初始化吗?