When dealing with values of varying lengths/sizes… What is the tradeoff between an Array of values and an array of pointers?
An array of values that have varying sizes means that you must accomodate the largest possible size… possibly using a relatively large amount of memory for empty data for the smaller-size values. However, the data is stored sequentially in memory, and so is more cache-friendly.
An array of pointers doesn’t waste memory space with empty data, but is no longer cache-friendly because the data is not necessarily sequential (the pointers just have addresses to whatever random part of memory is storing that value)
Zuletzt geändertvor einem Monat