- Joined
- Aug 7, 2013
- Messages
- 1,338
Hi,
If for some reason we allocate more structs than can be allowed for, what happens to the newly made structs?
Suppose I filled an array of this struct below, where it has a single field marking its position in my array.
I now have an array of myStruct[8192] which I have filled with 8192 unique instances of myStruct, as shown below.
Obviously if I print each member in my array and its field I should get this output.
0
1
2
...
8191
But what happens if I decide just to create another struct.
When I print out my array again, will this new struct have replaced one of the array members? So basically I'll see a -1 pop up in the middle of the print out, replacing one of the numbers.
0
1
2
...
//somewhere a has replaced a struct
-1
...
8191
If for some reason we allocate more structs than can be allowed for, what happens to the newly made structs?
Suppose I filled an array of this struct below, where it has a single field marking its position in my array.
JASS:
struct myStruct
integer i
static method create takes integer i returns thistype
...
endmethod
endstruct
I now have an array of myStruct[8192] which I have filled with 8192 unique instances of myStruct, as shown below.
JASS:
myStruct array myStructs[8192]
...
local integer i = 0
loop
exitwhen i == 8192
set myStructs[i] = myStruct.create(i)
set i = i + 1
endloop
Obviously if I print each member in my array and its field I should get this output.
0
1
2
...
8191
But what happens if I decide just to create another struct.
JASS:
local myStruct a = myStruct.create(-1)
When I print out my array again, will this new struct have replaced one of the array members? So basically I'll see a -1 pop up in the middle of the print out, replacing one of the numbers.
0
1
2
...
//somewhere a has replaced a struct
-1
...
8191