New implementations in Dictionary module
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
Re: New implementations in Dictionary module
Hi Eros,
your plan seems pretty good!
Maybe key list could use wildcart ( "rockets*" ... ) ?
Bye,
Petr
Re: New implementations in Dictionary module
Nice idea.
No easy to implement but worth to try.
Re: New implementations in Dictionary module
I don't quite understand what it does, but sounds interesting and will wait for the demos to see what goes on.
Re: New implementations in Dictionary module
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
Re: New implementations in Dictionary module
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
Re: New implementations in Dictionary module
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
Re: New implementations in Dictionary module
Thanks Eros,
that would be nice !
Bye,
Petr
Re: New implementations in Dictionary module
Eros wrote:
Quote:
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.
Re: New implementations in Dictionary module
When I see words like "Auto" and "Memory Handled" it always makes me Happy!!