> Use a structure-of-arrays rather than an array-of-structures.
instead of this:
struct World {
players: Vec<Player>
}
struct Player {
name: String,
health: i64,
}
which is a "array of structures", see Vec<Player>, you do this:
struct World {
player_names: Vec<String>,
player_health: Vec<i64>,
}
"A structure of arrays".
"Player zero" is no longer an index into a players array, but an index into many arrays, all of which hold certain kinds of data about a player.
> And that also allows you to reference deleted nodes?
... which is why the talk then references generational indices as a way of dealing with it.
instead of this:
which is a "array of structures", see Vec<Player>, you do this: "A structure of arrays"."Player zero" is no longer an index into a players array, but an index into many arrays, all of which hold certain kinds of data about a player.
> And that also allows you to reference deleted nodes?
... which is why the talk then references generational indices as a way of dealing with it.