The MASM Forum

Projects => ObjAsm => Topic started by: HSE on August 30, 2020, 10:05:07 AM

Title: Sort in SortedCollection
Post by: HSE on August 30, 2020, 10:05:07 AM
Hi Biterider!

SortedCollection work perfectly inserting items in order. :thumbsup:

Look like Sort after change Compare don't work at all.  Perhaps I'm missing the whole idea  :biggrin:
Title: Re: Sort in SortedCollection
Post by: Biterider on August 30, 2020, 06:34:24 PM
Hi HSE
You're right. There are two problems with the "Sort" method.
The first relates to the translation to x64 in line 179, which does not affect the 32-bit code.
The second is bad one. In line 178, an indirection is missing when the sorted item is reinserted.

I compiled the x86 and x64 versions and they seem to be working correctly.
I also attached the project because while reading the code I made some changes to format it the way I'm used to, but your original code is perfectly fine.

Biterider
Title: Re: Sort in SortedCollection
Post by: HSE on August 31, 2020, 12:24:15 AM
Thanks Biterider  :thumbsup:

For a complete example must be replace the second OCall pDamnVector::MyDamnVector.ForEach, addr SetPosition, MyDamn_Position_in_Age, 0

with:OCall pDamnVector::MyDamnVector.ForEach, addr SetPosition, MyDamn_Position_in_LW, 0


:biggrin: :biggrin: Just in case we lost malt measure: DbgFloat [xax].$Obj(MyDamn).r8Attr[MyDamn_ID*sizeof(REAL8)]

Regards. HSE
Title: Re: Sort in SortedCollection
Post by: Biterider on September 07, 2020, 06:58:04 AM
Hi HSE
I optimized the Sort method a bit. if dCount > 0, the first item is kept in place and the sorting starts with the second item.  :icon_idea:
Can you check, it all is working right in your application using this version?

Regards, Biterider
Title: Re: Sort in SortedCollection
Post by: HSE on September 07, 2020, 08:33:46 AM
Hi Biterider!

Fantastic  :thumbsup: