PDA

View Full Version : New implementations in Dictionary module



ErosOlmi
20-04-2007, 22:00
Hi all,

I'm working on Dictionary module to apply the following changes:

case insensitive keys DONE. Present in current release
key exists function DONE. Present in current release
dictionary count to get number of keys stored DONE. Present in current release
key list, to have the list of keys stored inside a dictionary DONE. Present in current release
data type, to be able to store data different from string: numbers or entire UDT TYPE
dictionary size to be able to know the total amount of data stored into a dictionary DONE. Will be present in next release
possibility to save/load Dictionary to/from disk file
APPEND in order to append new data to current one stored under a key
REMOVE in order to remove a key/data pair from the dictionary
Resize a dictionary
create a new dictionary merging other two
create a new dictionary with only common keys of other two
create a new dictionary with only not common keys
...
...
...
...


If you have any urgent request let me know here and I will try to give higher priority.

Regards
Eros

Petr Schreiber
20-04-2007, 22:11
Hi Eros,

your plan seems pretty good!
Maybe key list could use wildcart ( "rockets*" ... ) ?


Bye,
Petr

ErosOlmi
21-04-2007, 00:16
Nice idea.
No easy to implement but worth to try.

kryton9
21-04-2007, 06:01
I don't quite understand what it does, but sounds interesting and will wait for the demos to see what goes on.

ErosOlmi
21-04-2007, 09:53
Theory of Dictionary can be found at http://en.wikipedia.org/wiki/Hash_table
or also http://en.wikipedia.org/wiki/Associative_array
That is what's behind the scene.

Dictionary is also called in other languages in the following way:

hash table
collection
associative array

but all do (more or less) the same thing:

store data under a text key name
fast storing
superfast retrieving
efficient memory handling


In Dictionary every key is unique.
It means that every time you add a new key/data pair the Dictionary automatically check if the key is already present or not.
If key is not present it will be added to the dictionary and relevant data stored.
If key is already present no new duplicated key will be added but previous data will be replaced by new one.
All memory handling is done by the Dictionary so programmer doen not need to warry about it (unless data stored is a structure referencing other dynamic memory blocks).

Every single key/data pair can store up to 2Gb of data.
Of course this is theory because limits are imposed by physical memory present in the computer and by limits of some OS version but in any case can give you an idea of the power of a Dictionary.

... will continue

Petr Schreiber
21-04-2007, 10:01
Eros,

another idea, what about DICTIONARY_ASSIGN( pDict, keyName, Value ) ?
This would allow to overwrite data already present for key.

Useful could be also DICTIONARY_APPEND( pDict, keyName, Value ) to just append new data to those hidden under keyName.

To remove items there could be DICTIONARY_REMOVE( pDict, keyName ), and to empty whole dictionary just DICTIONARY_EMPTY( pDict ).


Bye,
Petr

ErosOlmi
21-04-2007, 10:13
Petr

In Dictionary every key is unique.
It means that every time you add a new key/data pair the Dictionary automatically check if the key is already present or not.
If key is not present it will be added to the dictionary and relevant data stored.
If key is already present no new duplicated key will be added but previous data will be replaced by new one.
All memory handling is done by the Dictionary so programmer doen not need to worry about it (unless data stored is a structure referencing other dynamic memory blocks).

I will add REMOVE functionality, very interesting.
Also APPEND is quite interesting. I will see what I can do.

Thanks a lot
Eros

Petr Schreiber
21-04-2007, 10:19
Thanks Eros,

that would be nice !


Bye,
Petr

catventure
21-04-2007, 12:15
Eros wrote:


In Dictionary every key is unique.
It means that every time you add a new key/data pair the Dictionary automatically check if the key is already present or not.
If key is not present it will be added to the dictionary and relevant data stored.
If key is already present no new duplicated key will be added but previous data will be replaced by new one.
All memory handling is done by the Dictionary so programmer doen not need to warry about it (unless data stored is a structure referencing other dynamic memory blocks).


Very interesting. I like it. And I like the autocheck - that will make life easier for programmer. Good work, Eros.

catventure.

kryton9
21-04-2007, 22:54
When I see words like "Auto" and "Memory Handled" it always makes me Happy!!

marcuslee
03-09-2008, 01:43
I'm working on Dictionary module to apply the following changes:



possibility to save/load Dictionary to/from disk file



If you have any urgent request let me know here and I will try to give higher priority.



I wouldn't call my need urgent. I'm only exploring. But, I thought this piece of the Dictionary module implentation was interesting. Have you worked on this part? If not, do you know how you will do it?

I had an idea in the past, even worked on it in Liberty Basic for a while, of creating a game like Who wants to be a Millionaire? Back then, more than a year ago, I was playing with the idea of using Random Access Files to store the questions, answers, as well as some other info for each question. This Dictionary module sounds like it might work, and opening a saved dictionary would be even awesomer (yeah yeah, I know ... not a word).

Mark

ErosOlmi
03-09-2008, 07:13
Well,

we usually give priority to what thinBasic users ask.
I will give a go to this request after next thinBasic will be out.

Ciao
Eros

Lionheart008
11-09-2008, 21:27
dear eros:-), hi all :-)

- although it's quite (yet) a unknown area for me, I have thought it will be useful to use the "dictionary" as the word in my language say in common to "translate" words, for example english into german or into spanish ;-).

- would be great to load "thumbnails" or "pics" to, perhaps even a "data base" of thinBasic Users here or "mp3" files? :-)

- the idea behind the dictionary is good! I have followed your first link to the hash module...

- to load/to save data from disk/dvd would be nice...

little input more...
I have understood your script as well as I tried it some minutes before to advance it...

good evening, servus, Lionheart
hope you have had a relaxed day ;-)

marcuslee
11-09-2008, 22:39
I wouldn't call my need urgent. I'm only exploring. But, I thought this piece of the Dictionary module implentation was interesting. Have you worked on this part? If not, do you know how you will do it?

I had an idea in the past, even worked on it in Liberty Basic for a while, of creating a game like Who wants to be a Millionaire? Back then, more than a year ago, I was playing with the idea of using Random Access Files to store the questions, answers, as well as some other info for each question. This Dictionary module sounds like it might work, and opening a saved dictionary would be even awesomer (yeah yeah, I know ... not a word).


This statement isn't as true anymore. I probably won't use the Dictionary feature in my current plans, so there is no urgent need from my perspective. I like the information I have found about using a Microsoft Access database with ODBC. That path seems to fit my current idea.

Although if the Dictionary module is to be popular, it would seem that a save feature would be not a plus but a requirement, but it isn't needed by me for the moment.

Mark 8)