[fpc-pascal] Hashmap for integers

Juha Manninen (gmail) juha.manninen62 at gmail.com
Sun Aug 22 17:36:23 CEST 2010

On Sunday 22 August 2010 17:34:55 Andreas Schneider wrote:
> uses fgl;
> type
>   TIntMap = specialize TFPGMap<Integer, Integer>; //Maps Int --> Int

Thanks. I tried that. However the class name, TFPGMap, turned out to be 
misleading. It inherits from TFPSMap which inherits from TFPSList, which is a 
list, not a map, as the name says.
Lists should be named as "List", not as "Map".

I already have a self-made TIntList. It has Quicksort and Find functions and 
it is as fast as can be. I made it years ago because I didn't find any proper 
alternative. (Java people don't need to do such things...)

Is it really so there is no generics HashMap container in fgl, or in other FPC 
libraries? Someone should make it!
And, the name "Map" should really be reserved for hash maps and not used for 
lists (= kind of poor man's map).

My prog has a big amount of integers, thats why an integer list is not enough. 
A binary search from a sorted list is pretty fast but the problem is that I am 
adding items to the list and it must be sorted after every addition.

My experience from string hashmaps says that the speed difference can be huge, 
compared to any list implementation.


More information about the fpc-pascal mailing list