January 2020
Intermediate to advanced
532 pages
13h 31m
English
The problem we just saw is caused by the use of an array of structs. What we really want is a struct of arrays. Notice the difference between arrays of structs and structs of arrays?
In an array of structs, to access a field for an object, the program must first index into the object and then find the field via a predetermined offset in memory. For example, the passenger_count field in the TripPayment object is the fourth field of the struct where the preceding three fields are Int64, String, and String types. So, the offset to the fourth field is 24. An array of structs has a row-oriented layout as every row is stored in a contiguous block of memory.
We now introduce the concept of struct ...
Read now
Unlock full access