Author Topic: Sort in SortedCollection  (Read 1530 times)

HSE

  • Member
  • *****
  • Posts: 2193
  • AMD 7-32 / i3 10-64
Sort in SortedCollection
« 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:
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 975
  • ObjAsm Developer
    • ObjAsm
Re: Sort in SortedCollection
« Reply #1 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

HSE

  • Member
  • *****
  • Posts: 2193
  • AMD 7-32 / i3 10-64
Re: Sort in SortedCollection
« Reply #2 on: August 31, 2020, 12:24:15 AM »
Thanks Biterider  :thumbsup:

For a complete example must be replace the second
Code: [Select]
OCall pDamnVector::MyDamnVector.ForEach, addr SetPosition, MyDamn_Position_in_Age, 0
with:
Code: [Select]
OCall pDamnVector::MyDamnVector.ForEach, addr SetPosition, MyDamn_Position_in_LW, 0

 :biggrin: :biggrin: Just in case we lost malt measure:
Code: [Select]
DbgFloat [xax].$Obj(MyDamn).r8Attr[MyDamn_ID*sizeof(REAL8)]
Regards. HSE
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 975
  • ObjAsm Developer
    • ObjAsm
Re: Sort in SortedCollection
« Reply #3 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

HSE

  • Member
  • *****
  • Posts: 2193
  • AMD 7-32 / i3 10-64
Re: Sort in SortedCollection
« Reply #4 on: September 07, 2020, 08:33:46 AM »
Hi Biterider!

Fantastic  :thumbsup:
Equations in Assembly: SmplMath