yeah...I see now....ok....well roll on lunchtime so I can test this out.

Cheers,

Jeremy Coulter
Application Developer

Application Development Centre
Compaq Computer New Zealand Ltd.

Phone:  64 3 371 5724
Fax:            64 3 371 5724
Mobile:       64 0212533214
E-mail: [EMAIL PROTECTED]       
Personal Email: [EMAIL PROTECTED]



-----Original Message-----
From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 17, 1999 11:03 AM
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Sorting


No..the parameter of sort is the PROCEDURE ItemCompare i.e. the sort method
then calls the paramter passed to it

You are used to passing variables to procedure as a parameter well here
you are passing a procedure as a parameter .. neat huh

Regards
Neven


----- Original Message -----
From: Coulter, Jeremy <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Wednesday, 17 November 1999 10:56
Subject: RE: [DUG]: Sorting


> ok, that does look simple enought, BUT you say you do
> "Mylist.Sort(ItemsCompare);" yet part of the function
> "function ItemsCompare(Item1, Item2: Pointer): Integer;" it requires 2
items
> to be passed to it.
> so, would it not be "Mylist.Sort(ItemsCompare(theItem1,TheItem2 ));"??
>
> Jeremy Coulter
> Application Developer
>
> Application Development Centre
> Compaq Computer New Zealand Ltd.
>
> Phone: 64 3 371 5724
> Fax:     64 3 371 5724
> Mobile:       64 0212533214
> E-mail: [EMAIL PROTECTED]
> Personal Email: [EMAIL PROTECTED]
>
>
>
> -----Original Message-----
> From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 17, 1999 10:26 AM
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Sorting
>
>
> Jeremy
>
> It quite simple really,  your list has to know what it is a list of so you
> define a sort procedure
> which compares 2 items (passed as untyped pointers
>
> e.g this is one I wrote
>
> function ItemsCompare(Item1, Item2: Pointer): Integer;
> var
>   MenuItem1, MenuItem2: TDBMenuItem;
> begin
>    Result := 0;
>    MenuItem1 := Item1;
>    MenuItem2 := Item2;
>    if MenuItem1.Level = MenuItem2.Level then
>    begin
>      if MenuItem1.Position = MenuItem2.Position then Result :=  0;
>      if MenuItem1.Position < MenuItem2.Position then Result :=  -1;
>      if MenuItem1.Position > MenuItem2.Position then Result :=  1;
>      Exit;
>    end;
>    if MenuItem1.Level < MenuItem2.Level then Result :=  -1;
>    if MenuItem1.Level > MenuItem2.Level then Result :=  1;
> end;
>
> then you call the sort method with the proc as parameter
>
> Mylist.Sort(ItemsCompare);
>
> easy once you start writing OO i.e define the items on your list as a
class
>
> regards
> neven
>
>
>
>
>
>
>
> ----- Original Message -----
> From: Coulter, Jeremy <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Sent: Wednesday, 17 November 1999 10:20
> Subject: RE: [DUG]: Sorting
>
>
> > I did look a this is in the begining, BUT I found it confusing how to
> > implement a sort.
> > I looked at a few excamples, but none really made any sence.
> >
> > Cheers,
> >
> > Jeremy Coulter
> > Application Developer
> >
> > Application Development Centre
> > Compaq Computer New Zealand Ltd.
> >
> > Phone: 64 3 371 5724
> > Fax:     64 3 371 5724
> > Mobile:       64 0212533214
> > E-mail: [EMAIL PROTECTED]
> > Personal Email: [EMAIL PROTECTED]
> >
> >
> >
> > -----Original Message-----
> > From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, November 17, 1999 10:10 AM
> > To: Multiple recipients of list delphi
> > Subject: Re: [DUG]: Sorting
> >
> >
> > Jeremy
> >
> > Use a TList and implement a sort on it .... see the Sort method of Tlist
> >
> > Regards
> > Neven
> >
> >
> > ----- Original Message -----
> > From: Jeremy Coulter <[EMAIL PROTECTED]>
> > To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> > Sent: Wednesday, 17 November 1999 08:28
> > Subject: [DUG]: Sorting
> >
> >
> > > Hi all.
> > >
> > > I have been working on a wee logfile analyzer component for myself.
> > > Basically it loads a CSV file(like one generated bt IIS) into memory
and
> > > then analyzes the entries.
> > > I.e. in the case of the CSV file from IIS which i am using for
> developing,
> > > it calculates how many times an IP adress appears, and calculates how
> many
> > > bytes were sent to that IP address, i.e. the result :=
> > 192.168.0.1,20,10000
> > > (ip address, number of times it appears, how man bytes)
> > >
> > > Anyway, one of the things I do is load the file into a TStringList,
and
> > then
> > > I sort it so i get all the, in this case, IP address grouped
togeither,
> > > which makes it easier to calculate everything, as all the relevient
data
> > is
> > > all togeiter.
> > >
> > > BUT, I have a 7322 line file, and if I sort it, the process of zipping
> > > through the file takes 22 seconds, remove the sorting, 0.461 seconds
> !!!!
> > >
> > > SO, is there a faster way of sorting ?
> > > Should I use an inmemory table...and if so, can I sort the fields
> etc.....
> > >
> > > Any suggestions,
> > >
> > > Cheers, Jeremy Coulter
> > >
> > >
> >
>
> --------------------------------------------------------------------------
> > -
> > >     New Zealand Delphi Users group - Delphi List -
[EMAIL PROTECTED]
> > >                   Website: http://www.delphi.org.nz
> > >
> >
>
> --------------------------------------------------------------------------
> -
> >     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
>
> --------------------------------------------------------------------------
> -
> >     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> >
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to