Recent

Author Topic: TFPGMap sort on data  (Read 490 times)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
TFPGMap sort on data
« on: February 06, 2023, 06:05:17 pm »
How can I sort a TFPGMap on data instead of on keys?
How should I use OnDataCompare and Sort?

Thanks.
Andrea

Thaddy

  • Hero Member
  • *****
  • Posts: 14210
  • Probably until I exterminate Putin.
Re: TFPGMap sort on data
« Reply #1 on: February 06, 2023, 06:56:31 pm »
Sorting on data is useless. Be more specific.
Specialize a type, not a var.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: TFPGMap sort on data
« Reply #2 on: February 06, 2023, 08:59:53 pm »
If you need data sorted on multiple keys, use multiple maps and define some procedure/methods that check them both for removal/addition.

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: TFPGMap sort on data
« Reply #3 on: February 06, 2023, 09:04:02 pm »
@Thaddy, I am using TFPGMap as a dictionary <integer, integer> and I need to sort by Data and not by Key. Why should be useless?

Should I use a different class? Why the method OnDataCompare is available if it is considered useless?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: TFPGMap sort on data
« Reply #4 on: February 06, 2023, 09:16:57 pm »
fpSmap seems to have an indexdata method. That seems the only place it is used, but it is an iteration, not a map.

 

TinyPortal © 2005-2018