Are Tuples list and dictonaries in fuze
-
@pianofire So there are only lists[]
Wow thats interesting -
@petermeisenstein I implemented a simple dictionary in this: https://fuzearena.com/forum/topic/781/persistent-data but it only sequentially searches the keys ( there is no hashing)
-
@pianofire And tuples are also not in fuze.And let guess they are not on the priority list what i can totaly understand because you dont really need tuples in fuze.Very cool your implementation.
-
You can use vectors as tuples of floats if you only need up to 4 elements. And since they're floats you can also store ints and boolean values. I've been doing this in my project. Other than that you could use a struct.
-
I implemented a very rudimentary hash table with some example code on usage. I may work on it some more if people like it. The code is SUK736X9SM.
Let me know what you think. There are no comments because I have been up way too late working on this. You may also notice that I had to use arrays to handle collisions as there are no pointers or reference values that I could figure out how to implement. Keep that in mind because you can quickly eat up a lot of memory if you make the table too large.
-
Thank you, @rubiks14, for this really useful hash table! It seems to be working fine, except that it needs one simple change to work in Fuze 2.15:
Change row 14 by adding the
ref
keyword like this:function addKeyValue(ref hashTable, key, value)
This should perhaps be added to the Functions section?
-
OK, I just realised that you also need to change line 26 to this:
function getValue(ref hashTable, key)
Otherwise a copy of the whole hash table is created for each call to getValue(), which slows everything down a lot, especially when you have large hash tables.
Also, line 38 should be:
function removeKeyValue(ref hashTable, key)
I hope @rubiks14 doesn't mind, but I will share the updated version for others who might need it.
-
@vinicity They haven't logged in for a few weeks but I guess they wouldn't have shared it if they didn't want people to use it
-
I've not worked with the lower-level workings of a hash table, so maybe I'm missing something about the implementation provided in the shared code. This still looks like its looping a collection to find the key, while my assumption was that the table would allow you to directly use the key without having to do any looping whatsoever, so I'm confused : ) If someone can give me a clue I'd appreciate it... perhaps @pianofire Thanks!
EDIT: Perhaps what I'm seeing now is that chaining is only being used for collisions, thus looping only rarely occurs??? : )
-
Yes, it’s only looping when collisions occur.
-
I had forgotten about this, but here is the hash function, with fixes to make it work in Fuze 2.15:
ID: 1P8Q3MND5C
-
@vinicity Thanks... I'll grab that! : )