Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
An Array v's A Dictionary
#11
(10-07-2024, 07:18 PM)Dimster Wrote: I've just recently come across a Dictionary as an alternative to an Array. Doesn't appear that QB64PE supports Dictionaries. Does anyone who codes in languages which do use Dictionaries find them the same as using an Array or better than an Array or offering a completely different manipulation of data than an Array?

Hi Dimster
we must remember the differences between array and dictionary

-array is a set of data of the same type of data in which elements are ordered by value of index of array that is a integer number
array definition, rosetta code
Array QB64 Rosetta code example

-dictionary is an associative array in which each element has  a key and a value, so searching for the key you get back the value

here a dictionary made using a string as container and delimiter characters to separate the couple Key-Value  rosetta code associative array QB64
and here the task definition of type of data Associative array

So we can think that dictionary mustn't keep ordered (increasing or decreasing) the Key side of the couple Key-Value and the search has been made looking from the start to the end of the dictionary in the Key side. 
A more evolute dictionary is a hashmap in which the Key value has direct access to the Value using a Hash formula.

In the forum you can find example of dictionary, associative arrays and hash formula.
But that posted by Bplus is a good start.
Reply




Users browsing this thread: 3 Guest(s)