Hello, I am using an array struct. Let's call it ExAS for the discussion.
When I call ExAS.create(), I see that the definition of create() typically involves assigning "this" to an integer.
So we see something like this:
and "Index" will be an integer for the index of a stack.
Now my question arises: if I have an arbitrary array struct and I'm using AutoIndex's GetUnitId() function, and I use
is there some significant memory usage that results from assigning index 8000 with no data in all the previous 8000 elements, and therefore I should use the array struct in a more controlled fashion?
Or is using the array struct like a hashmap (with GetUnitId() as the hash function) practical and safe? (Does WC3 allocate memory for all ~8190 elements of the array when I declare an array at all? In this case, it seems like there would be no difference between trying to formalize the structure of an ordinary array and simply using array struct as though it were a hashmap.)
I feel that if I could simply use an array struct like a hashmap from unit Id to struct instance then my life would be very easy. Then it would be easily to arbitrarily access the array struct ExAS and pull out any unit that I might want to check out.
EDIT: By "hashmap" I really just mean any sort of "dictionary" or "map" or "associative array" data structure.
When I call ExAS.create(), I see that the definition of create() typically involves assigning "this" to an integer.
So we see something like this:
JASS:
local ExAS this = Index
and "Index" will be an integer for the index of a stack.
Now my question arises: if I have an arbitrary array struct and I'm using AutoIndex's GetUnitId() function, and I use
JASS:
local ExAS this = GetUnitId(someUnit)
is there some significant memory usage that results from assigning index 8000 with no data in all the previous 8000 elements, and therefore I should use the array struct in a more controlled fashion?
Or is using the array struct like a hashmap (with GetUnitId() as the hash function) practical and safe? (Does WC3 allocate memory for all ~8190 elements of the array when I declare an array at all? In this case, it seems like there would be no difference between trying to formalize the structure of an ordinary array and simply using array struct as though it were a hashmap.)
I feel that if I could simply use an array struct like a hashmap from unit Id to struct instance then my life would be very easy. Then it would be easily to arbitrarily access the array struct ExAS and pull out any unit that I might want to check out.
EDIT: By "hashmap" I really just mean any sort of "dictionary" or "map" or "associative array" data structure.
Last edited by a moderator: