Legacy GM Set of arrays

GMWolf

aka fel666
I need to store a set of arrays in a way that would allow very fast adding/removing of any elements in the set. (so hashset, treeset, etc. A List would be too slow).

I must store the array given (not a copy of the array), as the array is used as keys throughout the project.

Im currently thinking of using a ds_map and be done with it but i first wanted to ask you if there where any better alternatives - It would be best if this system had the lowest cpu overhead possible (I can deal with slightly ugly).
The arrays used can be made longer to store any extra information to make this faster (like an index or something).

[edit] I also have to be able to itterate over this set fairly quickly.

Thanks for your help,
Felix
 
Last edited:

RangerX

Member
I suspect a 2D array is faster than a ds map but the ds map is a bit more optionated. You'd have to test what's more convenient for you
 

GMWolf

aka fel666
I suspect a 2D array is faster than a ds map but the ds map is a bit more optionated. You'd have to test what's more convenient for you
How would a use a 2d array to do this? The 2d Array allows me to have two integer keys. I need a single array key.
 

RangerX

Member
whatever type you need, I don't know what you're trying to achieve. I am saying arrays are faster. But data structures are more optionated.
 

Roa

Member
maps sound like the only option unless you want ot re-invent the wheel. What are you doing that using list is make or break? Like how many interations are we talking here?
 

GMWolf

aka fel666
maps sound like the only option unless you want ot re-invent the wheel. What are you doing that using list is make or break? Like how many interations are we talking here?
The trouble with lists is that removing a specific element is rather slow, (you have to itterate over the entire list to see where the element is, Then, in the case of array lists, you have to move all elements up. this is increadibly slow :'( ).
I think ill just end up using ds_maps :).
 
Maps are definitely the way to go. Given an arbitrary set of data and locating a specific value in that set, maps are the fastest method in the long run.
 

GMWolf

aka fel666
Maps are definitely the way to go. Given an arbitrary set of data and locating a specific value in that set, maps are the fastest method in the long run.
i think thats what ill end up doing.

Thanks :)

[edit] Ah, actually, the trouble with maps is itteration... i think ill have to implement my own hash sets or tree sets :'(
 
Last edited:
Top