Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-07

Hello,I suggest that you change the TFPGMap in fgl.

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

김봄

if TFPGMap::Sorted is True, then Add method time complexity is O(n) and Indexof,Find method is O(lg n).

or Sorted is False, then Add method is O(1) and Indexof,Find is O(n)

but, most language's map implementation is red/black tree or hashtable.

i don't know why free pascal's map is based on array.

if map implementation is hashtable or r/b tree, then Add,Indexof,Find method have a
log or constant time complexity.

please, answer my suggestion.

sorry for my english.

sincerely.

==

yonsei univ. in korea, kimbom.

ᐧ

Reply by email

leledumbo
to 김봄
i don't know why free pascal's map is based on array.

Because the unit was meant mainly for testing the generics support and if you read the line right before the unit clause:
https://github.com/graemeg/freepascal/blob/master/rtl/objpas/fgl.pp#L20

Still, there's no problem having array backed map, the convenience of map data structure is still achieved, it's just the speed that matters. Use fcl-stl instead, it has gmap which is rbtree backed and ghashmap which is hashtable backed.

Reply by email