Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / NameToNum

Author
Message
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Dec 2002 01:07
Some people have been wanting to use names/labels to determine which sprite/bitmap/object etc is used. NameToNum is a name to number mapper, designed to be as fast as possible to reduce as much time as possible in searching for names.

By association, the linklist routine it uses will also be availiable for use in DBPro - its advantages are that it deals with memory addresses (as opposed to TYPE's), and has a sorting routine; and get start searching from the middle of a link list.
Good news everyone! I really am THAT good...
Oh my, yes...
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Dec 2002 01:18
Why not use a map of strings to integers or dwords?

It's already sorted, and has a guaranteed fast binary search.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Dec 2002 01:48
When is it sorted ?

Good news everyone! I really am THAT good...
Oh my, yes...
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Dec 2002 01:50
Everytime you insert an item into the map, it is inserted at the correct sort position.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Dec 2002 02:05
That would be valid if everything was fixed size, length and number - however, everything is variable size to save memory.

It works like this :

Taking the first character of the name, it converts this to an index. The name, and any name that starts with the same first character is added to this index position.

It saves time, especially with large number of names.

Searching is done in the same way.

Good news everyone! I really am THAT good...
Oh my, yes...
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Dec 2002 02:39
The size of the key doesn't matter. You just set the map template key to char*, the data to int, and third to strcmp/stricmp.

Are you using a trie structure? Or an array of lists?
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Dec 2002 02:42
An array of link lists

Good news everyone! I really am THAT good...
Oh my, yes...

Login to post a reply

Server time is: 2024-03-28 09:56:58
Your offset time is: 2024-03-28 09:56:58