Hello,
It is easy to use parallel quicksort , you can sort strings , integers , reals, doubles etc
you can sort even sort then when they are inside objects.
Here is an example that i gave you inside the zip file, i am sorting strings that are inside objects:
:
---
program test;
uses parallelquicksort,sysutils,timer;
type
TStudent = Class
public
Name: string;
end;
var tab:Ttabpointer;
myobj:TParallelSort;
student:TStudent;
i:integer;
function comp(Item1, Item2: Pointer): integer;
begin
if TStudent(Item1).name < TStudent(Item2).name
then
begin
result:=-1;
exit;
end;
if TStudent(Item1).name > TStudent(Item2).name
then
begin
result:=1;
exit;
end;
if TStudent(Item1).name = TStudent(Item2).name
then
begin
result:=0;
exit;
end;
end;
begin
myobj:=TParallelSort.create(4); // set to the number of cores...
setlength(tab,100000);
for i:=low(tab) to high(tab)
do
begin
student:=TStudent.create;
student.name:= inttostr(i);
tab[high(tab)-i]:= student;
end;
HPT.Timestart;
myobj.pqsort(tab,comp);
writeln;
writeln('Time in microseconds: ',hpt.TimePeriod);
writeln;
writeln('Please press a key to continu...');
readln;
for i := LOW(tab) to HIGH(Tab)
do
begin
writeln(TStudent(tab).name,' ');
end;
for i := 0 to HIGH(Tab) do freeandnil(TStudent(tab));
setlength(tab,0);
myobj.free;
end.
---
Thank you,
Amine Moulay Ramdane.