View Full Version : Map or hash
slenkar
14-11-2010, 08:09 PM
Is there something in FreePascal that allows you to store and retrieve objects and give them keys ?
I see there is a thread called 'superfast hash' but I dont see the functions
'insert' and 'get'
JSoftware
14-11-2010, 09:08 PM
There should be a hashtable in contnrs.pas
chronozphere
14-11-2010, 10:13 PM
Seems like delphi doesn't have it. At least not there. :( Some more quick datastructures in the standard library would've been nice.
slenkar
14-11-2010, 11:04 PM
I downloaded one from here:http://www.benya.com/code/collections/hashtable.html
but when I try to retrieve an object it crashes:
this is the code im using to test the hashtable
s:=ship_array[0];
hashy.setValue('trev',s);
s:=spaceship(hashy.getValue('trev'));
but this line causes the crash:
function tHashEntry.getKey : tComparable;
begin
result := fKey;
end;
Traveler
15-11-2010, 09:05 AM
There is ThashedStringlist. I've used it for my latest project (non-gamedev related). It's easy to use and does the job well.
Brainer
18-11-2010, 03:51 PM
Seems like delphi doesn't have it. At least not there. :( Some more quick datastructures in the standard library would've been nice.
Check out the unit Generics.Collections (D2009/D2010/XE). :)
chronozphere
19-11-2010, 10:13 AM
Ah thanks. I guess I should really make the move to D2010 or XE. ;)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.